次の問題について教えてください。これは基本的なことですが、非常に基本的なものが欠けているようです。':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