blob: b42ade6f8adb18d9ef1aa7120ee1bf7a9a5041f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
class Program < ApplicationRecord
STRONG_LIFTS = "StrongLifts 5×5"
has_many :exercises, through: :routines
has_many :routines, inverse_of: :program
has_many :recommendations, through: :routines
before_save do
self.slug = name.parameterize
end
def to_param
slug
end
def next_routine_after(routine)
routines.where.not(name: routine.name).first
end
def prepare_sets_for(user, exercise)
recommendation = recommendation_for(user, exercise)
recommendation.prepare_sets
end
def recommendation_for(user, exercise)
UserRecommendation.new(user, exercise, self)
end
class << self
def stronglifts
Program.find_by(name: STRONG_LIFTS)
end
end
end
|