Hello,
I am new to ruby on rails. When I tried to create a session I am
getting an error, ‘wrong number of arguments (1 for 0)’, in my
controller.
ArgumentError in CustomerController#add_to_cart
wrong number of arguments (1 for 0)
RAILS_ROOT: /project/bob_shopping
Application Trace | Framework Trace | Full Trace
app/controllers/customer_controller.rb:36:in `session'
app/controllers/customer_controller.rb:36:in `add_to_cart'
My controller is …
def add_to_cart
if request.post?
product_id = params[:product_id]
quantity = params[:quantity]
account = get_account()
error)—> session[:cart] = SessionCart.new(account) if
session(:cart).nil?
session[:cart].add_product( product_id)
if quantity >= 2 and quantity <= 50
for i in 1…quantity-1
session[:cart].add_product(product_id)
end
end
flash[:notice] = ‘Your order has been placed.’
redirect_to :action=>‘index’ and return true
end
end
Waiting for your valuable reply..