你能帮我解决以下问题吗?我知道这是基本的,但我似乎缺少一些非常基本的东西。当我介绍 ':editors' 时,事情似乎出错了,尽管我指向了正确的类名。谢谢你的帮助。
我已将我的模型“页面”定义如下 -
class Page < ActiveRecord::Base
belongs_to :subject
has_many :sections
has_and_belongs_to_many :editors, :class_name => "AdminUser"
end
我的 AdminUser.rb 定义如下
class AdminUser < ActiveRecord::Base
has_and_belongs_to_many :pages
has_many :section_edits
scope :named, lambda {|first,last| where(:first_name => first, :last_name => last)}
end
但是当我去 rails 控制台并输入
Loading development environment (Rails 3.2.1)
>> page.editors
NameError: undefined local variable or method `page' for main:Object
from (irb):1