单击“添加”按钮,所选项目未添加到购物车 参数正确传递,请检查并帮助
Mysql2::Error: Unknown column 'items.cart_id'
in 'where clause': SELECT `items`.* FROM `items`
WHERE `items`.`disable` = 0 AND `items`.`cart_id` = 1 AND `items`.`id` = 13
这是我的代码
before_action :current_cart
private
def current_cart
if session[:cart_id]
cart = Cart.find_by(:id => session[:cart_id])
if cart.present?
@current_cart = cart
else
session[:cart_id] = nil
end
end
if session[:cart_id] == nil
@current_cart = Cart.create
session[:cart_id] = @current_cart.id
end
end
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name,:last_name])
end