On Jun 19, 2014, at 7:29 AM, Ronald Fischer wrote: > Walter Davis wrote in post #1150186: >> On Jun 19, 2014, at 2:09 AM, Ronald Fischer wrote: >> >>> Does this mean that I can't solve this with a *button*, but would have >>> to use a *link* instead? >> >> It's important to note that you may style a link to look like anything >> -- even a button. But you cannot remove the button-ness from an actual >> button and have it do anything besides submit the form containing it. > > I see. Maybe I'm using the wrong design here in the first place. Here is > what I am going to do: > > The user arrives the web page in question, from an overview page. The > overview page gives a list of all instances (in this case, of type > Card), by listing only the primary key of the instance. When the user > clicks on one of those keys, s/he arrives at a page displaying all the > data for this Card instance. > > At this point, I will give the user three choices: > > - delete the Card > - edit the Card > - show again the "list of all cards" > > My (probably stupid) idea was to write a "form" without input fields, > showing only the information on the cards, and having 3 buttons for > DELETE, EDIT and LIST. > > Now I understand that a submit button in a form helper for a form_for, > which has as argument an existing object, automatically calls the > "update" function. Thinking about it, this makes sense, and I now think > that I was misusing the form_for(). > > Maybe I should just output the data without using a form at all, and use > button_to() if I want the clickable part look or behave like buttons, or > use links and style them as buttons, as you pointed out. In any case, > using a form in my particular case, doesn't make much sense. Would you > agree on that? >
I think you would get a lot of mileage out of reading the REST article in Rails Guides. Particularly try to absorb how Rails does its own flavor of REST routing. To delete an object, you send a DELETE (header) request, which Rails simulates as a POST with a method: '_delete' hidden field, since most browsers don't properly support that request type. If you were to hand-make a form with such a method within it, wrapped around your delete button, then it would just work. But if you put that button inside a regular form_for @your_object, then the form will have either the POST (new object) or PUT/PATCH (existing object being updated) path and header, and the delete will fail. Walter > -- > Posted via http://www.ruby-forum.com/. > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/a1e40d17786e980f2fba3705ab8aade8%40ruby-forum.com. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/E9CEC60B-90BC-4BB4-90D3-2E2E20B34808%40wdstudio.com. For more options, visit https://groups.google.com/d/optout.

