-
Notifications
You must be signed in to change notification settings - Fork 3
/
models.rb
42 lines (31 loc) · 998 Bytes
/
models.rb
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
36
37
38
39
40
41
42
require 'data_mapper'
DataMapper.setup(:default, ENV['DATABASE_URL'])
class User
include DataMapper::Resource
property :id, Serial
property :name, String, { :required => true }
property :bio, Text, { :required => true }
property :email, String, { :required => true,
:unique => true,
:format => :email_address }
property :phone, String
property :website, String, { :format => :url }
has n, :jobs, { :child_key => [:user_id] }
has n, :skills, { :child_key => [:user_id] }
end
class Job
include DataMapper::Resource
property :id, Serial
property :job_title, String, { :required => true }
property :job_description, String, { :required => true }
property :company_name, String, { :required => true }
belongs_to :user
end
class Skill
include DataMapper::Resource
property :id, Serial
property :name, String, { :required => true }
belongs_to :user
end
DataMapper.finalize
DataMapper.auto_upgrade!