Sha256: 09010c29927ef2883a2026fcb7cb681a2f6659742fb83d3501df59d49b068d43

Contents?: true

Size: 434 Bytes

Versions: 6

Compression:

Stored size: 434 Bytes

Contents

module Sufia
  class TrophiesController < ApplicationController
    def toggle_trophy
      work_id = params[:id]
      authorize! :edit, work_id
      t = current_user.trophies.where(work_id: work_id).first
      if t
        t.destroy
        return false if t.persisted?
      else
        t = current_user.trophies.create(work_id: work_id)
        return false unless t.persisted?
      end
      render json: t
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sufia-7.2.0 app/controllers/sufia/trophies_controller.rb
sufia-7.1.0 app/controllers/sufia/trophies_controller.rb
sufia-7.0.0 app/controllers/sufia/trophies_controller.rb
sufia-7.0.0.rc2 app/controllers/sufia/trophies_controller.rb
sufia-7.0.0.rc1 app/controllers/sufia/trophies_controller.rb
sufia-7.0.0.beta4 app/controllers/sufia/trophies_controller.rb