Hi,
This is my definition of method “add_to_cart”
def add_to_cart
count=params[:product][:count]
while count.to_i>=0.to_i
if params[:product][‘dem_quantity’+count.to_s]==""
else
@product =
Product.find(params[:product][‘product_id’+count.to_s])
print @product.name
@product.update_attributes(params[:product][‘dem_quantity’+count.to_s])
end
count=count.to_i-1
end
end
With this method I am trying to just update values of the field “demand”
in the database corresponding to particular “id”. But when I m executing
this I m getting error like:-
undefined method `stringify_keys!’ for “5”:String
Application Trace of error is:-
C:/local/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1333:in
attributes=' C:/local/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1266:in
update_attributes’
#{RAILS_ROOT}/app/controllers/products_controller.rb:15:in `add_to_cart’
-e:3
What is wrong in above method?
Please tell me.
Thanx in advance.
Prash