Forum: Ruby on Rails using :post => 'true' still makes a GET request

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.
Sam D. (Guest)
on 2006-06-01 23:29
(Received via mailing list)
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.
Jeremy K. (Guest)
on 2006-06-01 23:48
(Received via mailing list)
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
Danny B. (Guest)
on 2006-06-02 01:59
> 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.
This topic is locked and can not be replied to.