Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Lesson < ActiveRecord::Base
- has_many :lessons_units, :foreign_key => "lesson_id",
- :dependent => :destroy
- has_many :units, :through => :lessons_units
- end
- class Unit < ActiveRecord::Base
- has_many :lessons_units, :foreign_key => "unit_id",
- :dependent => :destroy
- has_many :lessons, :through => :lessons_units
- end
- class LessonsUnits < ActiveRecord::Base
- attr_accessible :lesson_id, :unit_id
- belongs_to :unit
- belongs_to :lesson
- validates :unit_id, :presence => true
- validates :lesson_id, :presence => true
- end
- 1.9.3p194 :001 > Unit.lessons.build
- NoMethodError: undefined method `lessons' for #<Class:0x007fe733c29f30>
- from /Users/robert/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:50:in `method_missing'
- def create
- @unit = Unit.find(params[:unit_id])
- @lesson = @unit.lessons.build(params[:lesson])
- uninitialized constant Unit::LessonsUnit
- LessonsUnits -
- class LessonsUnits < ActiveRecord::Base
- class LessonsUnit < ActiveRecord::Base
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement