다음 문제를 해결할 수 있습니까? 이것은 내가 아는 기본이지만, 나는 아주 기본적인 것을 놓치고있는 것 같다. 내가 ': editors'라는 것을 소개했을 때 나는 올바른 클래스 이름을 가리키고 있지만 잘못된 것처럼 보인다. 당신의 도움을 주셔서 감사합니다.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
입니다. 죄송합니다. 작동하지 않습니다. –