我在我的 Test::Unit 输出中收到此警告...
/usr/local/bin/ruby -I.:lib:test -rtest/unit -e "%w[test/functional/sessions_controller_test.rb].each { |f| require f }" | unit_diff -u
Loaded suite -e
Started
.../Users/ethan/project/mtc/contactdb/app/views/sessions/new.html.haml:30: warning: multiple values for a block parameter (0 for 1)
from /usr/local/lib/ruby/gems/1.8/gems/haml-2.0.8/lib/haml/helpers/action_view_mods.rb:142
[...repeated eight times...]
我认为相关的部分是:
/contactdb/app/views/sessions/new.html.haml:30: warning:
multiple values for a block parameter (0 for 1)
查看我的 Haml 文件,我已将其缩小到这个片段(我认为)...
- form_tag( recover_login_path, :method => 'get') do |f|
%p
= text_field_tag :email, '', { :size => '35', :maxlength => '255' }
recover_login
是一个命名路由。
我查看了 form_tag
的 API 文档。看起来我的代码遵循了他们在示例中的内容。
最佳答案
form_tag
仅在您使用模型对象时传入表单构建器对象 |f|
。
form_tag @user, :method => :get do |f|
f.text_field :first_name
end
但是在没有传入模型对象的情况下构建自己的表单路径, block 参数没有被传入或使用。
form_tag user_path(@user.id), :method => :get do
text_field :user, :first_name
end
关于ruby-on-rails - 如何修复运行 Test::Unit 测试时产生的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/563231/