ActionView::Template::Error: wrong number of arguments (Simple Form)
ActionView::Template::Error: wrong number of arguments (Simple Form)
我有一个一直有效的 Rails 4 应用程序,但现在带有 simple_form_for 的页面生成错误。我删除了所有代码,只留下 simple_form_for 但我仍然收到错误。
错误页面(_form.html.erb):
<%= simple_form_for @anuncio do |f| %>
<%= f.input :titulo %>
<% end %>
当我执行这个页面时,我得到这个错误:
F, [2015-01-08T16:16:21.920151 #19971] FATAL -- :
ActionView::Template::Error (wrong number of arguments (3 for 2)):
1: <%= simple_form_for @anuncio do |f| %>
2: <%= f.input :titulo %>
3: <% end %>
config/initializers/simple_form.rb:100:in `block (2 levels) in <top (required)>'
app/views/anuncios/_form.html.erb:2:in `block in _app_views_anuncios__form_html_erb___4151327912554241759_53270140'
app/views/anuncios/_form.html.erb:1:in `_app_views_anuncios__form_html_erb___4151327912554241759_53270140'
app/views/anuncios/new.html.erb:3:in `_app_views_anuncios_new_html_erb___954346116733613916_53199500'
我发现了错误。我有一个自定义定义来在 simple_form.rb (config/initializers/simple_form.rb) 中呈现我的标签。在 "bundle update" 之后,我的 simple_form gem 更新了(到 3.1.0 版本,我的 actionview 也更新到 4.2.0)并且他们更改了传递给我的自定义参数def,破坏了应用程序。
之前 (config/initializers/simple_form.rb):
config.label_text = lambda { |label, required| "#{label}" }
更正:
config.label_text = lambda { |label, required, explicit_label| "#{label}" }
我有一个一直有效的 Rails 4 应用程序,但现在带有 simple_form_for 的页面生成错误。我删除了所有代码,只留下 simple_form_for 但我仍然收到错误。
错误页面(_form.html.erb):
<%= simple_form_for @anuncio do |f| %>
<%= f.input :titulo %>
<% end %>
当我执行这个页面时,我得到这个错误:
F, [2015-01-08T16:16:21.920151 #19971] FATAL -- :
ActionView::Template::Error (wrong number of arguments (3 for 2)):
1: <%= simple_form_for @anuncio do |f| %>
2: <%= f.input :titulo %>
3: <% end %>
config/initializers/simple_form.rb:100:in `block (2 levels) in <top (required)>'
app/views/anuncios/_form.html.erb:2:in `block in _app_views_anuncios__form_html_erb___4151327912554241759_53270140'
app/views/anuncios/_form.html.erb:1:in `_app_views_anuncios__form_html_erb___4151327912554241759_53270140'
app/views/anuncios/new.html.erb:3:in `_app_views_anuncios_new_html_erb___954346116733613916_53199500'
我发现了错误。我有一个自定义定义来在 simple_form.rb (config/initializers/simple_form.rb) 中呈现我的标签。在 "bundle update" 之后,我的 simple_form gem 更新了(到 3.1.0 版本,我的 actionview 也更新到 4.2.0)并且他们更改了传递给我的自定义参数def,破坏了应用程序。
之前 (config/initializers/simple_form.rb):
config.label_text = lambda { |label, required| "#{label}" }
更正:
config.label_text = lambda { |label, required, explicit_label| "#{label}" }