Rails 3 - CanCan错误? NameError(未初始化的常量Ability :: Invitation):

时间:2011-01-22 02:18:53

标签: ruby-on-rails ruby-on-rails-3 cancan

错误:

NameError (uninitialized constant Ability::Invitation):
  app/models/ability.rb:72:in `initialize'
  app/controllers/invitations_controller.rb:12:in `new'
  app/controllers/invitations_controller.rb:12:in `current_ability'
  app/middleware/flash_session_cookie_middleware.rb:14:in `call'

CanCan我有:

can :manage, Invitation
邀请函控制器中的

before_filter:current_ability #CanCan   load_and_authorize_resource #CanCan

def current_ability     @current_ability || = Ability.new(current_user,nil)   端

应用程序的控制器:

#CanCan
def current_ability
    @current_ability ||= Ability.new(current_user, nil) # since no group
end

路线:

resources :invitations

为什么CanCan不开心?感谢

1 个答案:

答案 0 :(得分:9)

看起来您正在尝试引用未定义的类。 app/models/invitation.rb是否有定义此Invitation类的文件?