Forum: Ruby on Rails scaffold uses link_to for destroy

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Peter M. (Guest)
on 2006-01-08 20:07
(Received via mailing list)
Hi,

I wonder why scaffolding uses a link_to tag for the destroy links.
Seems like these should be POST requests with button_to. The Rails
book dedicates pages 335-337 to this very issue.

Peter
Kevin O. (Guest)
on 2006-01-08 20:47
Peter M. wrote:
> Hi,
>
> I wonder why scaffolding uses a link_to tag for the destroy links.
> Seems like these should be POST requests with button_to. The Rails
> book dedicates pages 335-337 to this very issue.
>
> Peter

The scaffold is intended to be a quick and dirty implementation to get
things up and running.  The intent is for the user to gradually replace
scaffold operations with their own (and presumably better) code.  In
development mode

That said, I'm certain a signficant chunk of scaffold code will not be
replaced in some live applications.  It would certainly make sense to
put in minor fixes like that as an example of good coding practices at
least.

My guess is that the scaffold hasn't been updated in quite some time and
that this is a legacy thing.

FYI, you can make 'link_to' generate post requests instead of get
requests, so you don't really need to use 'button_to'.
Bruce B. (Guest)
on 2006-01-08 21:23
(Received via mailing list)
Kevin:

How do you get link_to to generate a post request?  That would seem
useful in light of this discussion.

bruce
David Heinemeier H. (Guest)
on 2006-01-08 22:14
(Received via mailing list)
> How do you get link_to to generate a post request?  That would seem
> useful in light of this discussion.

link_to "Destroy", { :action => "destroy" }, :post => true
--
David Heinemeier H.
http://www.loudthinking.com -- Broadcasting Brain
http://www.basecamphq.com   -- Online project management
http://www.backpackit.com   -- Personal information manager
http://www.rubyonrails.com  -- Web-application framework
Alain R. (Guest)
on 2006-01-10 00:55
(Received via mailing list)
Bruce

    > How do you get link_to to generate a post request?

An alternative is to replace
     link_to
by
    button_to

=> Rails creates a form and a button to reach the link target.


Alain
This topic is locked and can not be replied to.