mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 10:14:59 +00:00
Create device model and setup devise, activeadmin and rspec!
- with attributes: model, imei_number, unique_id and access_token - access_token is automatically generated on create
This commit is contained in:
6
app/models/admin_user.rb
Normal file
6
app/models/admin_user.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AdminUser < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
end
|
||||
9
app/models/device.rb
Normal file
9
app/models/device.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Device < ActiveRecord::Base
|
||||
validates :unique_id, :model, presence: true
|
||||
validates :unique_id, uniqueness: true
|
||||
before_create :generate_access_token
|
||||
|
||||
def generate_access_token
|
||||
self.access_token = SecureRandom.uuid
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user