Topic: Getting confused declaring models and their associations
I only just got started with Rails, and working on my first "production" app. The app will allow a user to schedule when the central Twilio number should call one of our doctors - basically, when he's on call.
I currently have 2 models:
Note that this forwarded_from is currently just the form input, but I might hardcode the phone numbers in the app. There will be 10 of them, but these obviously shouldn't change at all. If you think this is wrong, feel free to point out how you think I should handle this.
Now, I'm completely confused when I try to figure out what kind of association I should use between these models. The schedule will have a composite index on date and forwarded_from because you obviously can't forward a phone number to two different doctors on the same day. Is this a 1:many association, or many:many? In what direction? Maybe there's more than one possibility, and that's why I'm confused?
EDIT: currently thinking doctors has_many schedules, so that I can look up Doctor.schedules - I won't need to look up all Schedule.doctors as that makes no sense... right?
Last edited by hafos (2012-03-26 17:34:54)