small medium large xlarge

Generic-user-small
24 May 2010, 04:38
Joe Straitiff (7 posts)

So, I’m having trouble getting the image to be clickable and also add to the cart. I used the following link_to:

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

which produced the following html:

		<a href="/line_items?product_id=5" data-method="post" rel="nofollow"><img alt="Wd4d" src="/images/wd4d.jpg?1274594330" /></a>
		<h3>Web Design for Developers</h3>
		<p>
       <em>Web Design for Developers</em> will show you how to make your
       web-based application look professionally designed. We'll help you
       learn how to pick the right colors and fonts, avoid costly interface
       and accessibility mistakes -- your application will really come alive.
       We'll also walk you through some common Photoshop and CSS techniques
       and work through a web site redesign, taking a new design from concept
       all the way to implementation.
      </p>
		<div class="price_line">
			<span class="price">$42.95</span>

			<form method="post" action="/line_items?product_id=5"  class="button_to"><div><input type="submit" value="Add to Cart" /><input name="authenticity_token" type="hidden" value="6b0sGW99we5lx5SqoBZaS0EXLxP+D0lt+/mmrO3Dcfk=" /></div></form>
		</div>

The thing is, it’s just listing the products instead of posting the new product. Like it’s being called through with GET not POST… And idea why I’m getting this? I’m completely unfamiliar with the data-method=”post” bit up there.

-joe

Generic-user-small
24 May 2010, 07:58
Joe Straitiff (7 posts)

oki, I answered my own question, it’s the javascript_include_tag missing from app/views/layouts/application.html.erb. It was removed on p. 106 when overwritten by the version there.

So add back:

<%= javascript_include_tag :defaults %>

In the head before csrf_meta_tag and you’re golden.

You must be logged in to comment