small medium large xlarge

 

Pt-D-1

Andrew says:

I changed this line:


<%= image_tag(product.image_url) %>

... to …


<%= link_to(image_tag(product.image_url), 
            line_items_path(:product_id => product), 
            html_options = {:method => :post}) %>

Arun says:

The above works fine, but when I click the image, it directs to line_items show action, instead of cart(http://localhost:3000/line_items?product_id=3). Andrew, did you face this? How to direct it to cart’s show action?

Arun says:

I did it. Instead of using HTML call to post, I invoked the create method through rails. Works fine.

<%= link_to(image_tag(product.image_url), line_items_path(:product_id =>product), :method=> "create") %>

Martin says:

But finally “user friendly way” is:

<%= link_to image_tag(product.image_url, {:border => "0", :title => "Push it into cart!" 
|   |+carts/                   |    ->}), line_items_path(:product_id => product.id), {:method => :post} %>
Page History
  • V45: Mark Young [over 3 years ago]
  • V44: Mark Young [over 3 years ago]
  • V34: Chang Ju Park [over 3 years ago]
  • V33: Chang Ju Park [over 3 years ago]
  • V28: Pablo Rodriguez [about 4 years ago]
  • V26: Colm Morgan [about 4 years ago]
  • V25: Colm Morgan [over 4 years ago]
  • V24: Kevin Young [over 4 years ago]
  • V23: Aaron Burke [over 4 years ago]
  • V22: Aaron Burke [over 4 years ago]