0
0
Fork 0

Add BrowserDetection model concern (#29513)

This commit is contained in:
Matt Jankowski 2024-03-19 11:39:14 -04:00 committed by GitHub
parent d7ab5655ef
commit 62e266fbd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 29 deletions

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
module BrowserDetection
extend ActiveSupport::Concern
included do
before_save :assign_user_agent
end
def detection
@detection ||= Browser.new(user_agent)
end
def browser
detection.id
end
def platform
detection.platform.id
end
private
def assign_user_agent
self.user_agent ||= ''
end
end