Created
July 6, 2009 03:49
-
-
Save shelling/141253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "init" | |
p = Post.new | |
p.title = "first" | |
p.content = "hello world, this is my first entity" | |
p.save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "data_mapper" | |
$:.unshift "models" | |
DataMapper.setup( | |
:default, | |
"sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.sqlite3" | |
) | |
require "user" | |
require "post" | |
# DataMapper.auto_migrate! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post | |
include DataMapper::Resource | |
property :id, Serial, :key => true | |
property :title, String | |
property :content, Text | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "init" | |
p = Post.all | |
puts p.class | |
p.each do |ppp| | |
puts ppp.title | |
puts ppp.content | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
include DataMapper::Resource | |
property :id, Serial, :key => true | |
property :name, String | |
property :email, String | |
property :gender, String | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment