RoR E-Commerce - AJAX won't fire

Try

render :partial => ‘add_with_ajax’

Jason

Is this an error in the book? I am compiling a list of errata to post on my blog. Thanks.

Taylor Strait wrote:

I guess I should have read the logs:

ActionView::TemplateError (undefined method `book' for true:TrueClass) on line #2 of app/views/cart/add_with_ajax.rjs: 1: page.replace_html "shopping_cart", :partial => "cart" 2: page.visual_effect :highlight, "cart_item_#{@item.book.id}", :duration => 3 3: page.visual_effect :fade, "cart_notice", :duration => 3

Replacing the variable in line 2 with, "cart_item_#{@book.id}" fixed it. Thanks.

Hi Taylor,

For some reason your @item object is true, instead of the actual item. If you take a look at pages 154 and 155, you can see that @item = @cart.add(params[:id]) and that the add method should always return a cart item (on page 154), never a boolean value. So your fix works, but if your code is exactly as it is in the book, you should never get the error.

Cheers, //jarkko

Bala Paranj wrote:

Is this an error in the book? I am compiling a list of errata to post on my blog. Thanks.

Hi Bala,

I would appreciate if you could post all the errors you find directly to me, we're currently building an errata system to the companion site @ http://www.railsecommerce.com

Thanks, //jarkko