Commit b72c5a9
Changed files (4)
app
spec
controllers
app/controllers/workouts_controller.rb
@@ -28,6 +28,7 @@ class WorkoutsController < ApplicationController
:exercise_id,
:target_repetitions,
:target_weight,
+ :type,
]
)
end
app/models/exercise_set.rb
@@ -4,5 +4,11 @@ class ExerciseSet < ActiveRecord::Base
scope :for, ->(exercise) { where(exercise: exercise).order(:created_at) }
scope :successful, -> { where('actual_repetitions = target_repetitions') }
- enum type: { work: WorkSet.name, warm_up: WarmUpSet.name }
+ def work?
+ type == WorkSet.name
+ end
+
+ def warm_up?
+ type == WarmUpSet.name
+ end
end
app/views/workouts/new.html.erb
@@ -31,6 +31,7 @@
</div>
</div>
<p class="text-right"><a class="skip" href="#">skip</a></p>
+ <%= s.hidden_field :type %>
<%= s.hidden_field :exercise_id %>
</fieldset>
<% end %>
spec/controllers/workouts_controller_spec.rb
@@ -59,6 +59,7 @@ describe WorkoutsController do
exercise_id: squat.id,
target_repetitions: 5,
target_weight: 200,
+ type: 'WorkSet',
}]
}