大家好,大家在滑軌控制檯上遇到了一些麻煩。 這裏是錯誤。滑軌控制檯出現錯誤
>> Page.editors << me
NoMethodError: undefined method `editors' for #<Class:0x1038560e8>
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:50:in `method_missing'
from (irb):5
這裏是模型之間的關係。
class Page < ActiveRecord::Base
attr_accessible :name, :permalink, :position
has_and_belongs_to_many :editors, :class_name => "AdminUser"
#has_and_belongs_to_many :AdminUser
belongs_to :subject
has_many :sections
end
第二個
class AdminUser < ActiveRecord::Base
attr_accessible :first_name, :last_name, :email, :username
has_and_belongs_to_many :pages
scope :named, lambda{|first,last| where(:first_name => first,:last_name => last)}
end
我是新編程得益於它的工作 – skip87