我正在使用cancancan ..它在开发环境中运行良好..但是一旦我在生产中得到它,该网站就像没有安装任何宝石一样工作..没有授权处理。
我无法弄清楚出了什么问题
--------------------编辑 在应用程序控制器中有
before_filter :authenticate_user!, if: :devise_controller?
rescue_from CanCan::AccessDenied do |exception|
# Make sure we don't redirect to an HTML page
# in API requests because this is absolutely a bad idea
unless request.accept == 'application/json'
flash[:error] = "Access denied."
redirect_to root_url
end
end
并在能力档案中
def initialize(user)
# Define abilities for the passed in user here. For example:
#
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
else
can :index, Book
can :index, Category
end
end