Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

link_to does not merge parameters into request when :method => put

#3112

In an action view I have a line like this

link_to 'Update timestamp', order_path(order, :update_timestamp => true), :method => :put

The generated HTML, creates a link with a onclick attribute that ensures that the request is done via PUT (or rather "simulated put" using a POST), however this form does not include the parameter ":update_timestamp => true".

So the generated HTTP request when I click the link is a HTTP REQUEST is like this

POST /orders/12?update_timestamp=true HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 77
_method=put&authenticity_token=0CSVKo0DOV53oKiCV6f1qhE68VmEjroSgrZel5AgOxw%3D

But when it hits my controller the params is empty, where as I would have expected params[:order][:update_timestamp] == true

Jarl

Reported by Jarl Friis · August 28th, 2009 @ 10:05 AM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Jarl Friis
    Jarl Friis

    Sorry. My fault

    params is not empty, params[:order] is empty, but when I fixed it to

    link_to 'Update timestamp', order_path(order, :order => {:update_timestamp => true}), :method => :put
    

    Everything seems to work as expected.

    Jarl

    August 28th, 2009 @ 10:15 AM

  2. Jarl Friis
    Jarl Friis

    Please mark this as invalid.

    August 28th, 2009 @ 10:16 AM

  3. CancelProfileIsBroken
    CancelProfileIsBroken
    • State changed from new to invalid

    August 28th, 2009 @ 12:11 PM