Class: CountersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CountersController
- Defined in:
- app/controllers/counters_controller.rb
Overview
A stupid little controller showing how easy you can build generic “counter” functionality when they’re represented as a model
Instance Method Summary collapse
-
#destroy ⇒ Object
Reset a counter to 0.
-
#update ⇒ Object
Recalculate a counter.
Instance Method Details
#destroy ⇒ Object
Reset a counter to 0
5 6 7 8 9 |
# File 'app/controllers/counters_controller.rb', line 5 def destroy Counter::Value.find(params[:id]).reset! redirect_back fallback_location: "/" end |
#update ⇒ Object
Recalculate a counter
12 13 14 15 16 |
# File 'app/controllers/counters_controller.rb', line 12 def update Counter::Value.find(params[:id]).recalc! redirect_back fallback_location: "/" end |