首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ACL9和Rails 2.3.8 - NameError:未初始化的常量用户::角色

ACL9和Rails 2.3.8 - NameError:未初始化的常量用户::角色
EN

Stack Overflow用户
提问于 2010-11-24 17:42:20
回答 1查看 1.5K关注 0票数 2

我正在运行RVM (Ruby1.8.7-head,Rails 2.3.8),并且拥有运行新应用程序的基本知识。我有Authlogic工作,只有最低限度的代码才能做到这一点。我正在尝试使用ACL9 (我正在处理一个不同的项目,相同的RVM宝石集)。

代码语言:javascript
复制
class User < ActiveRecord::Base
    # authentication
  acts_as_authentic
  
  # authorization
  acts_as_authorization_subject
  
  def full_name
    "#{self.first_name} #{self.last_name}"
  end
end

当我试图运行一个简单的检查以确保ACL9正常工作时.

脚本/控制台

U= User.first

U.has_role?(任何角色)

我知道这个错误..。

代码语言:javascript
复制
ruby-1.8.7-head > u.has_role?(:anyrole)
NameError: uninitialized constant User::Role
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in `const_missing'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/base.rb:1:in `compute_type'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/base.rb:2230:in `compute_type'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/reflection.rb:156:in `send'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/reflection.rb:156:in `klass'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/reflection.rb:187:in `quoted_table_name'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/associations/has_and_belongs_to_many_association.rb:102:in `construct_sql'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:21:in `initialize'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/associations/has_and_belongs_to_many_association.rb:5:in `initialize'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/associations.rb:1306:in `new'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/activerecord-2.3.8/lib/active_record/associations.rb:1306:in `role_objects'
    from /Users/development/.rvm/gems/ruby-1.8.7-head@rails238/gems/acl9-0.12.0/lib/acl9/model_extensions/for_subject.rb:39:in `has_role?'
    from (irb):2

我不知道为什么这与我拥有的所有其他应用程序一起工作,但不是这个--我也不知道错误信息在说什么。任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-11-24 18:33:48

代码语言:javascript
复制
  class Role < ActiveRecord::Base
    acts_as_authorization_role
  end
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4269815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档