Class: Hyrax::TrophiesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Hyrax::TrophiesController
- Defined in:
- app/controllers/hyrax/trophies_controller.rb
Instance Method Summary collapse
Instance Method Details
#toggle_trophy ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/hyrax/trophies_controller.rb', line 5 def toggle_trophy work_id = params[:id] t = current_user.trophies.where(work_id: work_id).first if t (:destroy, t) t.destroy else t = current_user.trophies.build(work_id: work_id) (:create, t) t.save! end render json: t end |