DataMapper setup default sqlite3 Dir pwd mydatabase sqlite3 class Topi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/mydatabase.sqlite3")
class Topic
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, Text
property :added, DateTime
belongs_to :author, :class_name => 'User', :child_key => [:author_id]
end
class User
include DataMapper::Resource
property :id, Serial
property :login, String
has n, :topics
end
DataMapper.auto_migrate!