Using :post => 'true' still makes a GET request


#1

Hi,

In my link_to’s, i’m adding the additional parameter :post => ‘true’
whenever I expect to change database state on the server. Problem is,
when
I look at the incoming requests, I see that they are all coming in as
GET
requests instead of POST requests. Also, the link adds post=true as a
name
value parameter in the URL as it would with GET requests. I have
javascript
enabled in my browser.

Any help would be appreciated.

Thanks.


#2

On Jun 1, 2006, at 12:27 PM, Sam D. wrote:

In my link_to’s, i’m adding the additional parameter :post =>
‘true’ whenever I expect to change database state on the server.
Problem is, when I look at the incoming requests, I see that they
are all coming in as GET requests instead of POST requests. Also,
the link adds post=true as a name value parameter in the URL as it
would with GET requests. I have javascript enabled in my browser.

Any help would be appreciated.

Pass :post => true in the second hash argument:

link_to ‘here’, { :action => ‘here’, :id => 1 }, { :post => true }
link_to ‘here’, here_url(:id => 1), :post => true

jeremy


#3

Pass :post => true in the second hash argument:

link_to ‘here’, { :action => ‘here’, :id => 1 }, { :post => true }
link_to ‘here’, here_url(:id => 1), :post => true

Also, realize that, on clients with Javascript disabled, these links
will still use GET. So be sure to use something like

if request.post?
do_my_business
end

in your controller method.