Reputation: 9767
Run.rb:
has_many :schedule_machines, through: :schedule_locations
Schedule.rb:
has_many :schedule_locations, dependent: :destroy
has_many :schedule_machines, through: :schedule_locations
has_many :assigned_schedule_machines, through: :runs, source: :schedule_machines
has_many :runs, dependent: :destroy
when I look at a Schedule in the console,
schedule.assigned_schedule_machines
gives an undefined method.
How come?
Upvotes: 1
Views: 43
Reputation: 40277
has_many :runs, dependent: :destroy
has_many :assigned_schedule_machines, through: :runs, source: :schedule_machines
You need to order the "runs" first. The assigned_schedule wants to use runs; but in your original code the runs wasn't defined yet.
Upvotes: 3