'button_to' gives me an ugly URL!

Posted by Tyler on Stack Overflow See other posts from Stack Overflow or by Tyler
Published on 2010-04-28T04:59:13Z Indexed on 2010/04/28 5:03 UTC
Read the original article Hit count: 308

Filed under:
|
|
|
|

Im trying to get an 'add to cart' button to work. When I use <%= button_to "Add to Cart", :acton => "add_to_cart", :id => @product %> and then click the button, I get a URL that puts the action after the ID, like this: 'http://localhost:3000/store/show/1?acton=add_to_cart.' The cart page does not load.

What I need is a URL that looks like this: 'http://localhost:3000/store/add_to_cart/1'. I can get that result (and the cart to work) if I don't use 'button_to':

<% form_for @product, :url => {:action => "add_to_cart", :id => @product} do |f| %>

<% end %>

But, what the heck? Why can't I use 'button_to'?

© Stack Overflow or respective owner

Related posts about rails

Related posts about ruby