在我的项目中,我使用gem 'devise‘进行身份验证。一切都很好,但是在我的宝石档案中添加了宝石'cancancan‘之后。然后,我以用户身份登录,测试我的应用程序,并看到了"NameError at / uninitialized“。
项目伙伴文件:
gem 'devise'
gem 'carrierwave'
gem 'bootstrap-sass'
gem 'cancancan'
gem 'better_errors项目模式:
ability.rb文件:
class Ability
include CanCan::Ability
def initialize(user)
end
enduser.rb文件:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,:confirmable,
:recoverable, :rememberable, :trackable, :validatable
end项目控制器: main_controller.rb文件
class MainController < ApplicationController
load_and_authorize_resource
def index
end
def me
end
end我哪里做错了?请给我你的建议。
谢谢你,梅兹巴
发布于 2014-08-25 09:08:28
load_and_authorize_resource method is provided to automatically authorize all actions in a RESTful style resource controller
你只是没有Main模型
https://stackoverflow.com/questions/25480920
复制相似问题