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

Jake J. wrote:

link_to with the :post=>true?

This works pretty well

_Kevin

Kevin O. wrote:

Jake J. 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

Jake J. wrote:

Kevin O. wrote:

Jake J. 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}

_Kevin

Kevin O. wrote:

Jake J. wrote:

Kevin O. wrote:

Jake J. 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}

_Kevin

Yes, 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.

Tom M. wrote:

On Jan 22, 2006, at 12:26 PM, Kevin O. 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… :slight_smile:


– Tom M.

Yeah, 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

On Jan 22, 2006, at 12:26 PM, Kevin O. 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… :slight_smile:


– Tom M.