您能帮我解决以下问题吗?我知道这是基本的,但我似乎错过了一些非常基本的东西。当我介绍':编辑'的东西似乎出错了,虽然我指的是正确的类名。谢谢你的帮助。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 2012-02-13 18:03:59
对不起,不起作用。 – 2012-02-14 13:11:16