tab/app/models/client.rb
David Vandorpe 7e07debc91
Revert "Fix for WiNA"
This reverts commit eae4a3e99c.
2018-03-21 19:40:03 +01:00

24 lines
564 B
Ruby

# == Schema Information
#
# Table name: clients
#
# id :integer not null, primary key
# name :string not null
# key :string not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Client < ActiveRecord::Base
rolify
has_many :issued_transactions, as: :issuer, class_name: 'Transaction'
before_create :generate_key
validates :name, presence: true, uniqueness: true
private
def generate_key
self.key = SecureRandom.base64(16) unless self.key
end
end