views:

24

answers:

1

So..

<%= submit_tag 'Save', :name => 'save' %>
<%= submit_tag 'Save to Library', :name => 'library' %>

then in my controller:

with_action do |a|
    a.save do

    end

    a.library do

    end
end

the problem is that only one of the actions is getting invoked... the same one for both submit_tags... any idea why?

or how I can get two buttons to submit a form to two different methods?

+1  A: 

The submit button name attribute is passed to the controller as params[:commit]. So in your case:

if params[:commit] == "save"
end
Tanel Suurhans
I did a puts params,and there isn't a :commit key in the params hash... =\
DerNalia
What does the params hash contain?
Tanel Suurhans
When I use :name there is no :commit.wehn i don't use :name, the :commit is the text of the button
DerNalia
Then use the name instead of `:commit`.
Tomas Markauskas