-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.rb
More file actions
executable file
·35 lines (30 loc) · 779 Bytes
/
Copy pathmodels.rb
File metadata and controls
executable file
·35 lines (30 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'bundler/setup'
Bundler.require
if development?
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL']||"sqlite3:db/development.db")
end
class User < ActiveRecord::Base
has_secure_password
has_many :workspaces
validates :name,
presence: true,
uniqueness: true,
format: { with: /\A[0-9a-zA-Z]*\z/ },
length: { minimum: 7 }
validates :mail,
presence: true,
uniqueness: true,
format: { with: /\A([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])*\.([a-zA-Z0-9\._-]+)+\z/ }
validates :password_digest,
presence: true,
length: { minimum: 7 }
end
class Workspace < ActiveRecord::Base
has_many :keys
belongs_to :user
validates :url,
uniqueness: true
end
class Key < ActiveRecord::Base
belongs_to :workspace
end