views:

376

answers:

2

I'm getting this warning in my Test::Unit output...

/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...]

I think the relevant part is:

/contactdb/app/views/sessions/new.html.haml:30: warning: 
  multiple values for a block parameter (0 for 1)

Looking at my Haml file, I've narrowed it down to this snippet (I think)...

- form_tag( recover_login_path, :method => 'get') do |f|
  %p
    = text_field_tag :email, '', { :size => '35', :maxlength => '255' }

recover_login is a named route.

I looked at the API docs for form_tag. It seems like my code is following what they have in the examples.

+3  A: 

The form_tag block takes no parameters. So remove the |f| and the warning should go away.

Sarah Mei
+1  A: 

form_tag only passes in the form builder object |f| when you use a model object with it.

form_tag @user, :method => :get, do |f|
  f.text_field :first_name
end

But constructing your own form path with no passed in model object, the block argument is not passed in or used.

form_tag user_path(@user.id), :method => :get do
  text_field :user, :first_name
end
Squeegy