Sha256: 32a1967ad199ecb6ca58abd925e561335ed43ec14902773c0fd659e6bc8551ec
Contents?: true
Size: 657 Bytes
Versions: 1
Compression:
Stored size: 657 Bytes
Contents
class RequestLog < ActiveRecord::Base self.abstract_class = true serialize :request_body, JSON serialize :response_body, JSON belongs_to :loggable, optional: true, polymorphic: true scope :failed, -> { where("response_code not like '2%'") } validates :method, presence: true validates :path, presence: true def self.from_request(request) body = (request.body.respond_to?(:read) ? request.body.read : request.body).dup.force_encoding("UTF-8") begin body = JSON.parse(body) if body.present? rescue JSON::ParserError body end create(path: request.path, request_body: body, method: request.method) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_api_logger-0.2.5 | lib/rails_api_logger/request_log.rb |