pass parameter by link_to ruby on rails

后端 未结 4 772
孤城傲影
孤城傲影 2020-11-30 21:58

I have this line of code:

<%= link_to \"Add to cart\", :controller => \"car\", :action => \"add_to_cart\", :car => car %>

wh

4条回答
  •  [愿得一人]
    2020-11-30 22:23

    Maybe try this:

    <%= link_to "Add to cart", 
                :controller => "car", 
                :action => "add_to_cart", 
                :car => car.attributes %>
    

    But I'd really like to see where the car object is getting setup for this page (i.e., the rest of the view).

提交回复
热议问题