Sequences are acting as a join table between procedures and steps:
create_table "procedures", :force => true do |t|
t.integer "procedure_id"
t.integer "revision"
t.string "description"
end
create_table "sequences", :force => true do |t|
t.integer "procedure_id"
t.integer "step_id"
t.integer "step_number"
end
create_table "steps", :force => true do |t|
t.string "descriptor"
t.string "step_category"
t.string "step_type"
t.text "instructions"
end
What I am trying to do is to create a procedure, then create a step from the procedure, and have it save the step_number in the sequence associating the step and the procedure at the same time.
- Is there any good guide on how to do has_many :through? All I ever find is just how to make the model, I have no idea how to work with it.
- When saving my Step, do I need to explicitly create a Sequence? I was hoping Rails would automagically create it.
If anyone has some pointers on how to do this I would be glad to hear them, I'm having a lot of trouble setting this up.