Is the link_to help missing here in the wiki? I can’t find it and I’m stuck :(
The wiki has not been updated yet.
Take a look at the usages of
link_to on page 44 and 85. In particular, look at the link_to ‘Edit’ and ‘Destroy’ on the second page.
The documentation for link_to is available online. As applies here:
# The first parameter is what you want displayed on the screen. In this case, you will want to use the
image_tag that already is present in app/views/store/index.html.erb.
# The second parameter contains the target of the link. Use the same value for this link as is used on the call to
button_to later in app/views/store/index.html.erb.
# The third parameter is the html options. You will want to specify
:method => :post here.
Thanks for the reply Sam.
That was something I tried:
<%= link_to image_tag(product.image_url), line_items_path(:product_id => product), :method => :post %>
But when you click on the image to add to cart, it goes to the line_items listing page, and not the ‘Your Progmatic Cart’ page.
Have I missed something out? :-/
Very puzzling. From those symptoms, the
:method => :post is being ignored. As the default is
:get you are directed to the line items listing page.
Here’s what works on my machine, but I can’t see any difference (other than spacing) from what you tried:
<%= link_to image_tag(product.image_url), line_items_path(:product_id => product), :method=>:post %>
That gives me the same thing Sam :-/
I’m running Ruby 1.8.7 and Rails 3 beta 3.
I can’t seem to upgrade to beta4 (I get ‘file not found: lib’ :-/) could that be the issue?
(I’m running Snow Leopard)
Same problem here - the POST does not work.
Same thing on Beta4! =(
In other words: anyone who was following the book bottom-up, would get stumped like Aston and I did.
Nice one Alex!
So for anyone following, you need to add:
to the file:
As on page 107