Sha256: 1b157849d17d6176628ccd5365b295e376cefa998e40b958b11f188c25018a0d

Contents?: true

Size: 471 Bytes

Versions: 29

Compression:

Stored size: 471 Bytes

Contents

# frozen_string_literal: true
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

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.4 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.3 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.2 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.1 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.0 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.0.rc3 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.0.rc2 app/controllers/hyrax/trophies_controller.rb
hyrax-5.0.0.rc1 app/controllers/hyrax/trophies_controller.rb
hyrax-3.6.0 app/controllers/hyrax/trophies_controller.rb
hyrax-4.0.0 app/controllers/hyrax/trophies_controller.rb
hyrax-4.0.0.rc3 app/controllers/hyrax/trophies_controller.rb
hyrax-4.0.0.rc2 app/controllers/hyrax/trophies_controller.rb
hyrax-4.0.0.rc1 app/controllers/hyrax/trophies_controller.rb
hyrax-3.5.0 app/controllers/hyrax/trophies_controller.rb
hyrax-4.0.0.beta2 app/controllers/hyrax/trophies_controller.rb
hyrax-3.4.2 app/controllers/hyrax/trophies_controller.rb
hyrax-4.0.0.beta1 app/controllers/hyrax/trophies_controller.rb
hyrax-3.4.1 app/controllers/hyrax/trophies_controller.rb
hyrax-3.4.0 app/controllers/hyrax/trophies_controller.rb