Class: Consently::ConsentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Consently::ConsentsController
- Defined in:
- app/controllers/consently/consents_controller.rb
Overview
Records what the visitor agreed to, when, and against which policy version - the proof the GDPR asks for. The cookie remains the source of truth for what runs; this is bookkeeping.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/consently/consents_controller.rb', line 8 def create ConsentRecord.create!( categories: Array(params[:categories]).map(&:to_s).join(","), consent_version: params[:version].to_s, scope: Consently.scope_for(request).to_s.presence, subject: , user_agent: request.user_agent.to_s.first(255), ip_hash: hashed_ip ) head :no_content rescue ActiveRecord::StatementInvalid => error # Almost always the migration from `rails g consently:consent_log` not # having been run. The visitor's choice already took effect in their # browser, so this stays quiet and only complains in the log. Rails.logger.warn("[consently] could not record consent: #{error.}") head :no_content end |