Forum: Ruby on Rails Link_to with :method doesn't work for me (newbie)

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.
05f3e30611c7d1b4ad003f15ce0fc99e?d=identicon&s=25 Peter Laurens (nexum)
on 2009-03-15 22:01
Hi,

I have a nice link which I intend to have non-idempotent consequences
and so after a quick google I realized I want to use link_to with the
:method => :post option.

Only problem is that this stubbornly refuses to work for me. Using this
option produces HTML like:

<a href="/events/moderate?method=post">

clearly here this is not being interpreted correctly.

I updated my rails today to 2.2.2. But I don't know if I need to update
my application also. I tried using the older :post => true method too,
but it got turned into a GET Url also.

Is my rails project somehow outdated?

Thanks for any help you nay offer!
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-15 22:39
(Received via mailing list)
On Mar 15, 9:01 pm, Peter Laurens <rails-mailing-l...@andreas-s.net>
wrote:
> Hi,
>
> I have a nice link which I intend to have non-idempotent consequences
> and so after a quick google I realized I want to use link_to with the
> :method => :post option.

Looks like you are doing

link_to 'foo', :some_routing_param => 'bar', :method => :post

If you do that then method => :post ends up in the hash of url
parameters which isn't what you want. You want it to be in the second
hash of html options, which means you need to do
link_to('foo', {:some_routing_params => 'bar', ...}, :method => :post)

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