Created
April 11, 2009 17:02
-
-
Save shelling/93627 to your computer and use it in GitHub Desktop.
getting start with DataMapper
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 | |
# simple connect to database with DataMapper | |
require "rubygems" | |
require "data_mapper" | |
DataMapper.setup( | |
:default, | |
"sqlite3:///tmp/dm-core.sqlite3" | |
) | |
class Post | |
include DataMapper::Resource | |
property :id, Integer, :serial => true | |
property :name, String, :key => true | |
property :notes, Text, :lazy => false | |
property :create_at, DateTime | |
end | |
Post.auto_migrate! | |
post = Post.new | |
post.name = "shelling" | |
post.notes = "hello world" | |
post.create_at = DateTime.now | |
post.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment