我遇到了这种错误,之前它穿着正确,但有些错误是怎么回事。
undefined method `save' for 2:Fixnum
这是我在 line_item_controller.rb/create 中的代码
def create
@cart = current_cart
product = Product.find(params[:product_id])
@line_item = @cart.add_product(product.id)
respond_to do |format|
if @line_item.save
format.html { redirect_to store_url}
format.js { @current_item = @line_item }
format.json { render :json => @line_item, :status => :created, :location => @line_item }
else
format.html { render :action => "new" }
format.json { render :json => @line_item.errors, :status => :unprocessable_entity }
end
end
end
请帮忙!