On 6 March 2013 12:59, Jonathon Martin
<jonathondsmartin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''ve been researching this for some time and there
doesn''t seem to be an
> easy solution.
>
> I have a form_for that submits materials. As usual, when it edits an
> existing material it automatically goes to the update action. This is fine.
> However, I want to have a second submit button "Save As" that
allows a user
> to save another version of the material. This second button should then go
> to the ''create'' action.
>
> I tried changing the form_for and added the :url => choose_action_path.
Then
> in the controller the choose_action_path would then use the parameters sent
> through the button to decide whether to redirect_to
''create'' or ''update'',
> but it is not working.
>
> This must be a common need surely. Is there a good solution?
You are asking for a change to the html spec as the action is defined
in the form tag not the submit tag. That is not something that Rails
can change for you. If you want multiple submit buttons doing
different things then a common technique is to give the buttons
different name attributes (name="save", name="create") and
so on.
Then, in the controller, test the name to determine which button was
pressed and take appropriate action.
Colin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/6Qivls9H3AUJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.