Jake Janovetz
2006-Jan-22 19:44 UTC
[Rails] Destructive behavior with link_to, button_to, :post=>true
Hello- I would like to know what the suggested practice is for having multiple submit buttons on a relatively complicated input page. Let''s use the example of a Contact. There is lots of info there, including name, address, phone number. There is also a list of "contact associations" which can be modified on the same page. Ideally, the user could have one "Update" button to update all the regular information and then another button to do the "Add contact association". But each association would also have a "Delete" button to remove that association. It''s been suggested that POSTs be used for delete behavior rather than regular links. My typical way of doing this is to use "submit tags" within forms. But these aren''t well suited for inline behavior since you can''t nest forms and they also have problems since they are blocks. So, what''s the "right" way to do this? link_to with the :post=>true? button_to (not my favorite due to the nested form difficulty) Jake -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Jan-22 19:54 UTC
[Rails] Re: Destructive behavior with link_to, button_to, :post=>tru
Jake Janovetz wrote:> link_to with the :post=>true?This works pretty well _Kevin -- Posted via http://www.ruby-forum.com/.
Jake Janovetz
2006-Jan-22 20:08 UTC
[Rails] Re: Destructive behavior with link_to, button_to, :post=>tru
Kevin Olbrich wrote:> Jake Janovetz wrote: >> link_to with the :post=>true? > > This works pretty well > > _KevinGreat. Now, to add to the question a bit -- what if I have a selection of those contacts and want to relay which one was selected to the link_to w/post? Do I need to add a Javascript thing to go fetch that value from the selection item? Then add the selected "id" to the link? Jake -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Jan-22 20:26 UTC
[Rails] Re: Destructive behavior with link_to, button_to, :post=>tru
Jake Janovetz wrote:> Kevin Olbrich wrote: >> Jake Janovetz wrote: >>> link_to with the :post=>true? >> >> This works pretty well >> >> _Kevin > > > Great. Now, to add to the question a bit -- what if I have a selection > of those contacts and want to relay which one was selected to the > link_to w/post? > > Do I need to add a Javascript thing to go fetch that value from the > selection item? Then add the selected "id" to the link? > > Jakelink_to {:action=>''action'', :id=>object.id}, {:post=>true} _Kevin -- Posted via http://www.ruby-forum.com/.
Jake Janovetz
2006-Jan-22 20:33 UTC
[Rails] Re: Destructive behavior with link_to, button_to, :post=>tru
Kevin Olbrich wrote:> Jake Janovetz wrote: >> Kevin Olbrich wrote: >>> Jake Janovetz wrote: >>>> link_to with the :post=>true? >>> >>> This works pretty well >>> >>> _Kevin >> >> >> Great. Now, to add to the question a bit -- what if I have a selection >> of those contacts and want to relay which one was selected to the >> link_to w/post? >> >> Do I need to add a Javascript thing to go fetch that value from the >> selection item? Then add the selected "id" to the link? >> >> Jake > > link_to {:action=>''action'', :id=>object.id}, {:post=>true} > > _KevinYes, but the problem is that the data I''d like to send along with the link_to action is within form elements. Using a normal submit/form would send this along with the POST, but not the link_to. I think I''m better off just tweaking my form to suit what is possible here. -- Posted via http://www.ruby-forum.com/.
Tom Mornini
2006-Jan-22 21:40 UTC
[Rails] Re: Destructive behavior with link_to, button_to, :post=>tru
On Jan 22, 2006, at 12:26 PM, Kevin Olbrich wrote:>> Do I need to add a Javascript thing to go fetch that value from the >> selection item? Then add the selected "id" to the link? >> >> Jake > > link_to {:action=>''action'', :id=>object.id}, {:post=>true}link_to {:action=>''action'', :id=>object}, {:post=>true} .id is assumed. Rails is about less code... :-) -- -- Tom Mornini
Kevin Olbrich
2006-Jan-22 21:50 UTC
[Rails] Re: Re: Destructive behavior with link_to, button_to, :post
Tom Mornini wrote:> On Jan 22, 2006, at 12:26 PM, Kevin Olbrich wrote: > >>> Do I need to add a Javascript thing to go fetch that value from the >>> selection item? Then add the selected "id" to the link? >>> >>> Jake >> >> link_to {:action=>''action'', :id=>object.id}, {:post=>true} > > link_to {:action=>''action'', :id=>object}, {:post=>true} > > .id is assumed. > > Rails is about less code... :-) > > -- > -- Tom MorniniYeah, I know. I prefer to be a little more explicit when writing examples in case the reader didn''t know that. Actually I think it calls the to_param method so it can really be anything. _Kevin -- Posted via http://www.ruby-forum.com/.