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?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---