Ruby on Rails を使用して、ジムのワークアウト プランを作成できるようにしたいと考えています。ワークアウト プランは名前で構成され、X 日間のエクササイズが X 日間行われます。
これは、ワークアウトプランがどのように見えるかです
名称:ビギナーワークアウト
- 1日目
- 演習 1
- 演習 2
- 演習 3
- 2日目
- 演習 1
- 演習 2
- 3日目
- 演習 1
- 演習 2
- 演習 3
- 演習 4
これで、演習は特定のプール (私が入力) から取得され、ユーザーはそこから (チェックボックスで) 選択できます。
これは、新しいワークアウト プランを作成するための簡略化されたフォームです。
今のところ、一定の日数を持っていて、動的に日数を追加することは私の次のステップですが、今のところ重要ではありません。
現在、私は3つのモデルを持っています。プラン、プランデイ、エクササイズ。関係は
# == Schema Information
#
# Table name: plans
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
#
class Plan < ActiveRecord::Base
has_and_belongs_to_many :plan_days
accepts_nested_attributes_for :plan_days
end
# == Schema Information
#
# Table name: plan_days
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
#
class PlanDay < ActiveRecord::Base
has_and_belongs_to_many :exercises
accepts_nested_attributes_for :exercises
end
# == Schema Information
#
# Table name: exercises
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
#
class Exercise < ActiveRecord::Base
has_and_belongs_to_many :plan_days
end
私は上記のような形に本当に近づくことができず、私の関係が間違っているのではないかと思います. 助けていただければ幸いです、ありがとう。