I'm struggling to model a particular relationship with ActiveRecord. I currently have the following setup and working
class Schedule < ActiveRecord::Base
has_many :tasks
end
class Task < ActiveRecord:Base
belongs_to :schedule
end
with a database structure that looks like this:
schedules
- integer:id
tasks
- integer:id
- integer:schedule_id
What I'd like to be able to do is set one of the tasks to be the active task for a schedule by adding an "active_task_id" column to the Schedules table:
schedules
- integer:id
- integer:active_task_id
tasks
- integer:id
- integer:schedule_id
What I'm struggling with is how I should describe this within my ActiveRecord classes