Files
growstuff/app/resources/base_resource.rb
Daniel O'Connor 54acc369ab Rubocop
2025-09-20 09:43:22 +00:00

17 lines
467 B
Ruby

# frozen_string_literal: true
class BaseResource < JSONAPI::Resource
abstract
%i(create update remove).each do |action|
set_callback action, :before, :authorize
end
# Check authorisation for write operations.
# NOTE: At a later time, we may require API tokens for READ operations.
def authorize
# context[:action] is simply context[:controller].params[:action]
context[:current_ability].authorize! context[:action].to_sym, @model
end
end