bensaufley/fitness_schedules — pull request #3 by shterrett (2012-08-07 11:33:56+00:00)
Title: Many-to-many

Many-to-many relationship between client and trainers implemented; code changed to work with this paradigm.

Basic changes:
if client.trainer == current_user has been changed to if client.trainers.include?(current_user)
client.schedule.trainer has been replaced with a one-to-many trainer-schedule relationship: schedule.trainer
schedules now has a trainer_id column
client#edit automatically inserts trainer_id of logged-in trainer into schedule on create

Issues:
client#edit - don't know how to access underlying iterator and label the schedules. I can add a field for trainer_id easily enough, but that doesn't mean anything to the logged in trainers. One workaround would be to add a trainer_name column to schedules, have it automatically populated based on the trainer_id, and have an editable field for that. However, this is not preferable, because an exception will be thrown if the trainer attempts to edit the name to one that doesn't exist. And if the name is changed, but the id isn't, the record will be weird. I believe the database can be set so that the column cannot be changed, if it comes to that.

Next steps:
I will continue to prosecute the client#edit page. We need to style the client#new, trainer#new, reports#new and reports#show pages. I also have more work to do on reports#show.

We also need to decide how we want to handle storing the reps/weight of exercises as integers - we should have a quick chat about how to do this but keep it flexible and simple.