Re: [Rails] Save and delete buttons: POST vs. proximity dilemma
by Justin Forder other posts by this author
Sep 1 2005 9:57PM messages near this date
[Rails] Save and delete buttons: POST vs. proximity dilemma
|
Re: [Rails] Save and delete buttons: POST vs. proximity dilemma
Michael Schuerig wrote:
> I'm in a dilemma: In order to keep GET requests from deleting objects,
> I'd like to use the button_to helper to get "something" that generates
> a POST request. Unfortunately, that something is a form and forms can't
> be nested.
button_to was a strange addition to Rails - it goes against the grain of
HTML. A form defines the scope of content being submitted, and a submit
control (button) represents a way of submitting it. Unless you use
client-side script you are stuck with the single action URL associated
with the form.
http://ppewww.ph.gla.ac.uk/~flavell/www/trysub.html
discusses the use of multiple submit buttons, with working examples.
> I'd also like to place buttons related to the same form close to each
> other. At the top are some navigational buttons (links), then comes the
> delete button somewhere in the middle, at the bottom is the save
> button. Achieving this without having all of these buttons in the same
> form doesn't appear to be possible.
>
> Has anyone managed to solve this?
>
> The best idea I have right now is to use submit buttons in the same
> single form, but differentiate them by name. Then, in a before_filter,
> I could redirect the delete to the actual delete action. I can't say
> that this feels good.
Why redirect?
In Struts, you would use a DispatchAction or a LookupDispatch action to
route to a particular method of the action class based on the value of a
parameter in the HTTP request. LookupDispatchAction does this
indirectly, doing a reverse lookup on the message resources used to
define the names for the submit controls - so it it will work properly
with a multilingual application.
Could Rails' routing handle this?
regards
Justin
_______________________________________________
Rails mailing list
Rails@[...].org
http://lists.rubyonrails.org/mailman/listinfo/rails
Thread:
Michael Schuerig
Justin Forder
Tom Reinhart
Markus
Michael Schuerig
rails
Steve Downey
Michael Schuerig
Jarkko Laine
|