Hi,
I am implementing shopping cart and getting error in add_to_cart.
The error is:
ActiveRecord::AssociationTypeMismatch in StoreController#cart
Product expected, got Fixnum
The add_to_cart method is:
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
redirect_to(:action =>‘display_cart’)
rescue
logger.error(“Attempt to access invalid product #{params[:id]}”)
flash[:notice] =‘Invalid product’
redirect_to(:action => ‘index’)
end
render_text product.id is giving id of the product.
Can anyone tell me how to solve it?