Обновлен до Rails 4.0, внезапно передаю два аргумента

#ruby-on-rails

#ruby-on-rails

Вопрос:

После обновления Rails gem с 3.2 до 4.0 я получаю эту ошибку:

 Completed 500 Internal Server Error in 332ms

ActionView::Template::Error (wrong number of arguments (2 for 1)):
     5:       %th Activities
     6:       %th.w140
     7:   %tbody
     8:     - (list = latest_updates_list(@filter[:latest_updates_options])).each do |item|
     9:       %tr= latest_updates_item_helper(item)
    10:
    11:     - if list.length == 0
  app/helpers/dashboard_helper.rb:35:in `latest_updates_list'
  app/views/dashboard/_index.html.haml:8:in `_app_views_dashboard__index_html_haml__3752706349525323962_70305528188080'
  app/views/dashboard/index.html.haml:6:in `_app_views_dashboard_index_html_haml__2066908720777569268_70305520107720'
  

Это драгоценные камни, которые были обновлены:

 Updated gems

Using activesupport 4.0.0 (was 3.2.18)
Using builder 3.1.4 (was 3.0.4)

Using rack 1.5.5 (was 1.4.5)

Using actionpack 4.0.0 (was 3.2.18)

Using actionmailer 4.0.0 (was 3.2.18)
Using activemodel 4.0.0 (was 3.2.18)

Using activerecord-deprecated_finders 1.0.4

Using arel 4.0.2 (was 3.0.3)
Using activerecord 4.0.0 (was 3.2.18)

Using railties 4.0.0 (was 3.2.18)
Using coffee-rails 4.0.1 (was 3.2.2)

Using postgres_ext 2.0.0 (was 1.0.0)

Using sprockets 2.8.3 (was 2.2.2)

Using rails 4.0.0 (was 3.2.18)

Using sass 3.2.19 (was 3.3.5)
Using sass-rails 4.0.5 (was 3.2.6)

  

Это метод ‘latest_updates_list’:

 def latest_updates_list(option=nil )
    client_ids = current_user.actual_client_ids

    services = {}
    # binding.pry
    Service.where(:client_id => client_ids).each{|s| services[s.id] = {:name => s.name, :frequency_name => s.frequency_short_text, :per_hour => s.per_hour?} }
    #Service.where(true).each{|s| services[s.id] = {:name => s.name, :frequency_name => s.frequency_short_text, :per_hour => s.per_hour?} }

    reports = []
    invoices = []
    tickets = []
    employees = []

    list = []
    case option.to_sym
    when :reports
      reports = Report.for_latest_updates(client_ids) if (user_admin? || user_can_report?)
    when :invoices
      invoices = Invoice.for_latest_updates(client_ids) if (user_admin? || user_can_invoice?)
    when :tickets
      tickets = Ticket.for_latest_updates(client_ids) if (user_admin? || user_can_ticket?)
    when :employees
      employees = Employee.for_latest_updates(current_user.filter_client_id, client_ids) if user_admin?
    else
      reports = Report.for_latest_updates(client_ids) if (user_admin? || user_can_report?)
      invoices = Invoice.for_latest_updates(client_ids) if (user_admin? || user_can_invoice?)
      tickets = Ticket.for_latest_updates(client_ids) if (user_admin? || user_can_ticket?)
      employees = Employee.for_latest_updates(current_user.filter_client_id, client_ids) if user_admin?
    end

    list  = reports.collect do |r|
       {
         :date => r.updated_at,
         :entity => 1,
         :status_text => latest_update_report_status_text(r),
         :reports_services_text => latest_updates_reports_services_text(r, r.reports_services),
         :report_id => r.id}
    end unless reports.empty?

    list  = invoices.collect do |i|
       {
         :date => i.updated_at,
         :entity => 2,
         :status_text => latest_update_invoice_status_text(i),
         :invoice_reports_services_text => latest_updates_invoice_reports_services_text(services, i.reports),
         :invoice_id => i.id}
    end unless invoices.empty?

    list  = tickets.collect do |t|
       {
         :date => latest_update_ticket_date(t),
         :entity => 3,
         :status_text => latest_update_ticket_status_text(t),
         :description => t.description_text,
         :ticket_id => t.id}
    end unless tickets.empty?

    list  = employees.collect do |e|
       {
         :date => e.updated_at,
         :entity => 4,
         :description => e.text_for_stream,
         :employee_id => e.employee_id}
    end unless employees.empty?

    sorted_list = list.sort{|a, b| a[:date].to_i <=> b[:date].to_i}
    list = sorted_list.reverse!
    list = list.take(50)
  end
  

Когда я закомментирую первые 3 ‘list = …. do …’, тогда приложение загрузится, кроме того, что не получит информацию, которую они получают. Я ничего не изменил в этом коде, так что это должно быть связано с обновлением gem.

Ответ №1:

Проблема решена, это была проблема с устаревшим камнем postgres_ext.