Skip to content

Instantly share code, notes, and snippets.

@shelling
Created July 6, 2009 03:49
Show Gist options
  • Save shelling/141253 to your computer and use it in GitHub Desktop.
Save shelling/141253 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "init"
p = Post.new
p.title = "first"
p.content = "hello world, this is my first entity"
p.save
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!
class Post
include DataMapper::Resource
property :id, Serial, :key => true
property :title, String
property :content, Text
end
#!/usr/bin/env ruby
require "init"
p = Post.all
puts p.class
p.each do |ppp|
puts ppp.title
puts ppp.content
end
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