Class: Trackguard::Admin::BlockedUserAgentsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/trackguard/admin/blocked_user_agents_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
# File 'app/controllers/trackguard/admin/blocked_user_agents_controller.rb', line 10

def create
  record = BlockedUserAgent.find_or_create_by!(pattern: params.fetch(:pattern))
  Rails.cache.delete(BlockedUserAgent::CACHE_KEY)
  render json: { status: "ok", pattern: record.pattern }
rescue ActionController::ParameterMissing, ActiveRecord::RecordInvalid => e
  render json: { status: "error", message: e.message }, status: :unprocessable_entity
end

#indexObject



6
7
8
# File 'app/controllers/trackguard/admin/blocked_user_agents_controller.rb', line 6

def index
  render json: BlockedUserAgent.order(:pattern).pluck(:pattern)
end