Rails 4查看帮助程序:参数数量错误

tzz*_*zoz 0 ruby-on-rails view-helpers ruby-on-rails-4

我正在将项目从rails 3升级到rails 4.当我切换到rails 4时,我在日志中遇到了这个错误.但是我没有把这个方法传递给任何论据.

ActionView::Template::Error (wrong number of arguments (1 for 0)):
    1: <div id="titles_list">
    2:
    3:   <div id="admin_title_select_group">
    4:     <% table_group = select_table_group %>
    5:     <%= select_tag 'selected_group', options_for_select(table_group, by_default_selected_group) %>
    6:   </div>
    7:
  app/helpers/admin/titles_helper.rb:14:in `select_table_group'
  app/views/admin/titles/index.html.erb:4:in `_app_views_admin_titles_index_html_erb__3791160006166460542_70179046974220'
  lib/metal/search_store.rb:17:in `call'
Run Code Online (Sandbox Code Playgroud)

index.html.erb

<div id="titles_list">

  <div id="admin_title_select_group">
    <% table_group = select_table_group %>
    <%= select_tag 'selected_group', options_for_select(table_group, by_default_selected_group) %>
  </div>
...
Run Code Online (Sandbox Code Playgroud)

这是我的帮手方法:

module Admin::TitlesHelper

  def select_table_group
    g = [[I18n.t('admin.tpgn.select_group'),0]]
    g += TitleProviderGroupName.all(:order => :name).collect{|t| [ t.name, t.id ]}

  end

  def by_default_selected_group
    if params[:tpgn_id]
      params[:tpgn_id]
    else
      0
    end
  end

end
Run Code Online (Sandbox Code Playgroud)

它在rails 3中运行良好.在rails 4中有没有关于helper方法的变化?我没有找到任何关于此的信息.

Eye*_*dic 5

所有的方法没有考虑在轨道4,5参数.

TitleProviderGroupName.all
Run Code Online (Sandbox Code Playgroud)

必须改为

TitleProviderGroupName.order(:name)
Run Code Online (Sandbox Code Playgroud)