small medium large xlarge

1462547_10152030424046354_172793474_o_pragsmall
27 Oct 2008, 23:18
Giuseppe Caruso (22 posts)

I was trying to update the exercise to add a link to add items to the cart on books’ images in the “Iteration d2” using an Ajax call. I tried to change the previous:

<%= link_to image_tag(product.image_url), :action => "add_to_cart", :id => product, :method => :post %>

</code> to

<%= link_to_remote image_tag(product.image_url), :update => "cart", :url => { :action => :add_to_cart, :id => product }  %>

</code> but I just got errors. I have to say that I just tried to use logic to build the image link, I absolutely didn’t know how to do it. Please, could someone show me the right syntax?

1462547_10152030424046354_172793474_o_pragsmall
27 Oct 2008, 23:33
Giuseppe Caruso (22 posts)

A little update. Looking at the APIs about “link_to_remote” I edited the code to:

<%= link_to_remote(image_tag(product.image_url), :update => "cart", :url => { :action => :add_to_cart, :id => product }) %>

But with no luck. I am not able to understand where is the error. Thanks in advance to everyone.

1462547_10152030424046354_172793474_o_pragsmall
31 Oct 2008, 23:08
Giuseppe Caruso (22 posts)

Ok… I am on page 142, now I know why anyone replied to this topic… :P I am going to sneak peak the playtime discussion section of the book on the site. ;)

1462547_10152030424046354_172793474_o_pragsmall
31 Oct 2008, 23:17
Giuseppe Caruso (22 posts)

Ok, not so fast… just the “add the link_to_remote to images” exercise is missing… can anyone try to add it? I am not able to make my code working.

1462547_10152030424046354_172793474_o_pragsmall
02 Nov 2008, 16:52
Giuseppe Caruso (22 posts)

I would like to let you all know that I added it to the Playtime Wiki, you can find the section page “here”:http://pragprog.wikidot.com/task-d-a-dash-of-ajax You can participate to the discussion “here”:http://pragprog.wikidot.com/pt-d-0

1462547_10152030424046354_172793474_o_pragsmall
02 Nov 2008, 17:59
Giuseppe Caruso (22 posts)

Got the solution, you can find it at the playtime wiki linked above.

You must be logged in to comment