あなたは次の問題で私を助けてくれますか?私が知っているのは基本的ですが、私は何か非常に基本的なものが欠けているようです。私が紹介したときには、正しいクラス名を指していますが、編集者のことは間違っているようです。ご協力いただきありがとうございます。私は以下のように私のモデル 'のページ' を定義しているNameError:未定義のローカル変数またはメソッド
-
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
以下
として定義されていますが、私は、コンソールをレールに行くときにされ、タイプ
Loading development environment (Rails 3.2.1)
>> page.editors
NameError: undefined local variable or method `page' for main:Object
from (irb):1
こんにちは、大文字と小文字は区別されますか?あなたはクラスページを持っていますし、エラーではpage.editorsが小文字である – Downpour046
申し訳ありませんが動作しません。 –