I'm just diving into Datamapper (and Sinatra) and have a question about associations. Below are some models I have. This is what I want to implemented. I'm having an issue with Workoutitems and Workout. Workout will be managed separately, but Workoutitems has a single workout associated with each row.
Workout - just a list of types of
workouts (run, lift, situps, etc)
Selected workout - this
is the name of a set of workouts,
along with notes by the user and
trainer. It has a collection of N
workoutitems
Workoutitems - this takes a workout and a number of repetitions to it that go in the workout set.
class Workout
include DataMapper::Resource
property :id, Serial #PK id
property :name, String, :length=50,:required=true # workout name
property :description, String, :length=255 #workout description
end
class Selectedworkout
include DataMapper::Resource
property :id, Serial
property :name, String, :length=50, :required=true
property :workout_time, String, :length=20
property :user_notes, String, :length=255
property :coach_notes, String, :length=255
has n, :workoutitems
end
class Workoutitem
include DataMapper::Resource
property :id, Serial
property :reps, String, :length=50, :required=true
belongs_to :selectedworkout
end