small medium large xlarge

29 Mar 2010, 11:10
Ricardo (3 posts)

Hi, I am fine until D1 Iteration, but now I am stuck in the D2, when the “Add to cart” button tries to update the cart. I really have tried solve it seeing the book discussions about RJS error, but still I can’t solve the problem.

the “Add to cart” button response says:

try {Element.update("cart", "<h2>hello</h2>\n");}\n
 catch (e) 
    { alert('RJS error:\n\n' + e.toString()); 
      alert('Element.update(\"cart\", \"<h2>hello</h2>\\n\");'); 
      throw e }


I have followed all the book instrunctions code, but for simplifying, I have the most simple cart template: _cart.html.erb: ~~~



The store layout, *store.html.erb* includes

<%= stylesheet_link_tag "depot", :media => "all" %> <%= javascript_include_tag :defaults %>

<%= render(:partial => “cart”, :object => @cart) %>


The store controller, *store_controller.rb* includes

def add_to_cart product = Product.find(params[:id]) @cart = find_cart @cart.add_product(product) respond_to do |format| format.js end #redirect_to_index rescue ActiveRecord::RecordNotFound logger.error(“Attempt to access invalid product #{params[:id]}”) redirect_to_index(“Invalid product”) end ~~~ </code>

The add_to_cart.js.rjs file includes

page.replace_html("cart", :partial=>"cart", :object=>@cart )


I appreciate a lot any help

30 Mar 2010, 02:51
Sam Ruby (633 posts)

Check app/views/store/index.html.erb for :remote=>true. Pay special attention to the parenthesis and braces.

31 Mar 2010, 10:53
Ricardo (3 posts)

For some strange reason I had the public/javascripts folder missing … thanks for take a look

You must be logged in to comment