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:
Yedhu Krishnan
2015-10-16 18:37:08 +05:30
parent 2329533c56
commit 9c4800e217
24 changed files with 1097 additions and 1 deletions

9
app/models/device.rb Normal file
View 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