Sha256: 455f61ffacdbd7911eb31ebf69bdf0e75afccc9ddcdd66a7e3641c4787ea5e2f

Contents?: true

Size: 441 Bytes

Versions: 57

Compression:

Stored size: 441 Bytes

Contents

module Hyrax
  class TrophiesController < ApplicationController
    before_action :authenticate_user!

    def toggle_trophy
      work_id = params[:id]
      t = current_user.trophies.where(work_id: work_id).first
      if t
        authorize!(:destroy, t)
        t.destroy
      else
        t = current_user.trophies.build(work_id: work_id)
        authorize!(:create, t)
        t.save!
      end
      render json: t
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/controllers/hyrax/trophies_controller.rb
hyrax-2.9.5 app/controllers/hyrax/trophies_controller.rb
hyrax-2.9.4 app/controllers/hyrax/trophies_controller.rb
hyrax-2.9.3 app/controllers/hyrax/trophies_controller.rb
hyrax-2.9.2 app/controllers/hyrax/trophies_controller.rb
hyrax-2.9.1 app/controllers/hyrax/trophies_controller.rb
hyrax-2.9.0 app/controllers/hyrax/trophies_controller.rb
hyrax-2.8.0 app/controllers/hyrax/trophies_controller.rb
hyrax-2.7.2 app/controllers/hyrax/trophies_controller.rb
hyrax-2.7.1 app/controllers/hyrax/trophies_controller.rb
hyrax-2.7.0 app/controllers/hyrax/trophies_controller.rb
hyrax-2.6.0 app/controllers/hyrax/trophies_controller.rb
hyrax-3.0.0.pre.rc1 app/controllers/hyrax/trophies_controller.rb
hyrax-3.0.0.pre.beta3 app/controllers/hyrax/trophies_controller.rb
hyrax-2.5.1 app/controllers/hyrax/trophies_controller.rb
hyrax-2.5.0 app/controllers/hyrax/trophies_controller.rb
hyrax-3.0.0.pre.beta2 app/controllers/hyrax/trophies_controller.rb
hyrax-2.4.1 app/controllers/hyrax/trophies_controller.rb
hyrax-3.0.0.pre.beta1 app/controllers/hyrax/trophies_controller.rb
hyrax-2.4.0 app/controllers/hyrax/trophies_controller.rb