Simple question - several submit_tags for multiple actions


Started with Rails just a couple days ago and got stuck in two ways - I
like it (and would like to learn more) and cannot really figure out how
to use the submit_tag within the form_tag to initiate alternative
actions depending on which submit was chosen. One submit should function
exactly like the edit/update action from the initial scaffold while the
other should do the same plus change some additional fields.

Thanks a lot, Alex

Hello again,

actually found a solution from Peter in early April. Works fine.

Cheers, Alex

"Posted by Peter M. (Guest)
on 09.04.2006 06:07

I think you can only submit one form at a time. But there is a solution.

Make your whole page one big form that submits to a particular action.

For each “sub-form” make a button with a unique name. tags or <input type=button name="little_form_1>.
You don’t use submit tags for this.

For the entire form make a button with a unique name.

In the action that will process the form you will make a if else

if params[:all_forms]

elseif params[:little_form_1]


The above syntax may be a bit suspect but I’ve used something like
this before. I think it is nice an clean. I’ve found that it is best
if forms submit their data back to the same action that created the
form. This makes life easier. It also helps a lot with validation and


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs