0
我正在尝试创建一个会话。我的动作看起来是这样的:ProductCategoriesController中的NoMethodError#index
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def prepare_cart
session[:cart] = {} if session[:cart].empty?
end
end
为了这个,我正在错误:
NoMethodError in ProductCategoriesController#index
undefined method `empty?' for nil:NilClass
不能找到了什么的probem。它第一次运作良好。当我重新浏览器时,这个错误开始出现。请帮忙!
感谢男人..工作就像一个宝石.. –