DISQUS

Agile SharePoint Development by 21apps: Working through Agile Web Development with Rails – Part 3

  • Stuart · 2 years ago
    Thank you so much for this - was having the same problem!
  • Anonymous · 1 year ago
    I'm still having problems in FireFox, IE, and Safari.


    I noticed the author updated the code so it now reads on two lines:



    current_item = CartItem.new(product)

    @items << current_item



    (I tried it on one line like you wrote but but I still have the error). The cart does get updated but I need to hit F5 to refresh the page. I noticed too in the add_to_cart function of store controller.rb (see below), if I use redirect_to_index then I can click on an image and it adds the product to my cart and renders it properly. However if I use the respond_to { |format| format.js} I get a page in safari that displays a try block with an enormous Element.update call.







    def add_to_cart

    begin

    product = Product.find(params[:id])

    rescue ActiveRecord::RecordNotFound

    logger.error("Attempt to access invalid product #{params[:id]}")

    redirect_to_index("Invalid Product")

    else

    @cart = find_cart

    @current_item = @cart.add_product(product)

    #respond_to { |format| format.js }

    redirect_to_index

    end

    end