Hi everybody got some trouble with the rails console .
here is the error.
>> 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
here is the relation between the models.
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
the second one
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
This is wrong…it should be
The editors is an instance method which is made automatically through the associations..refer to the Rails Guide for more information…