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

发布于 2024-10-14 07:05:28 字数 862 浏览 2 评论 0原文

错误:

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

在 Invitations Controller 中:

before_filter :current_ability # CanCan load_and_authorize_resource #CanCan

def current_ability @current_ability ||= Skill.new(current_user, nil) 应用

程序的控制器:

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

路线:

resources :invitations

有什么想法 CanCan 不高兴吗?谢谢

Error:

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'

In CanCan i have:

can :manage, Invitation

in the Invitations Controller:

before_filter :current_ability # CanCan
load_and_authorize_resource #CanCan

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

Application's controller:

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

Routes:

resources :invitations

Any thoughts why CanCan isn't happy? thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-10-21 07:05:28

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

Looks like you are trying to reference a class that is not defined. Is there a file at app/models/invitation.rb that defines this Invitation class?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文