何が問題で、どうすれば修正できますか?
me = AdminUser.find(1)
実行してから実行すると、次のエラーが表示されますme.section.edits
NoMethodError: undefined method `section' for #<AdminUser:0x007fa539ee0558>
from ...gems/activemodel-3.2.13/lib/active_model/attribute_methods.rb:407:in `method_missing'
from ...gems/activerecord-3.2.13/lib/active_record/attribute_methods.rb:149:in `method_missing'
私のコード
create_section_edits.rb
class SectionEdit < ActiveRecord::Base
attr_accessible :title, :body, :name, :position
belongs_to :editor, :class_name => "AdminUser", :foreign_key => 'admin_user_id'
belongs_to :section
end
admin_user.rb
class AdminUser < ActiveRecord::Base
attr_accessible :title, :body, :username, :first_name, :last_name
has_and_belongs_to_many :pages
has_many :section_edits
scope :named, lambda {|first,last| where(:first_name => first, :last_name => last)}
end
section.rb
class Section < ActiveRecord::Base
attr_accessible :title, :body, :name, :position
belongs_to :page
has_many :section_edits
end
section_edit.rb
class SectionEdit < ActiveRecord::Base
attr_accessible :title, :body, :name, :position
belongs_to :editor, :class_name => "AdminUser", :foreign_key => 'admin_user_id'
belongs_to :section
end