Tidy up homepage and navigation
This commit is contained in:
18
app/models/dsn.rb
Normal file
18
app/models/dsn.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Dsn < ApplicationRecord
|
||||
validates :key, presence: true, uniqueness: true
|
||||
validates :name, presence: true
|
||||
|
||||
before_validation :generate_key, on: :create
|
||||
|
||||
scope :enabled, -> { where(enabled: true) }
|
||||
|
||||
def self.authenticate(key)
|
||||
enabled.find_by(key: key)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_key
|
||||
self.key ||= SecureRandom.hex(32)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user