gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 13:53:11 25 4
gpt4 key购买 nike

错误:

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

在邀请 Controller 中:

before_filter :current_ability # CanCan load_and_authorize_resource #CanCan

定义当前能力 @current_ability ||= Ability.new(current_user, nil) 结束

应用程序的 Controller :

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

路线:

resources :invitations

知道为什么 CanCan 不开心吗?谢谢

最佳答案

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

关于ruby-on-rails - Rails 3 - CanCan 错误? NameError(未初始化的常量 Ability::Invitation):,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4765739/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com