我希望能夠使用Ruby on Rails爲健身房創建鍛鍊計劃。鍛鍊計劃將包括一個名字,他將有X天的數量,這將有X個練習。使用Rails鍛鍊計劃模型與練習日程和練習
這是一個鍛鍊計劃是什麼樣子
名稱:初學者鍛鍊
- 日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
我真的不能接近上述的形式,我認爲我的關係也許是不正確的。我將不勝感激任何幫助,謝謝。
這是不是真的是我想做的事情,但感謝你 – 2013-02-21 23:06:27