Created
December 30, 2011 06:25
-
-
Save oza/1538250 to your computer and use it in GitHub Desktop.
datamapper with postgresql sample
This file contains hidden or 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 'data_mapper' | |
DATABASE_URL="postgres://[email protected]:5432/test" | |
DataMapper.setup(:default, DATABASE_URL) | |
class Rabbit | |
include DataMapper::Resource | |
property :id, Serial, :key => true | |
property :name, String | |
property :color, String | |
def inspect | |
"<#{self.class}:#{self.id},#{self.name},#{self.color}>" | |
end | |
end | |
Rabbit.auto_upgrade! | |
rabbit = Rabbit.new | |
rabbit.name = 'Jitterbug' | |
rabbit.color = 'orange' | |
rabbit.save! | |
Rabbit.create({:name => 'Mokha', :color => 'chestnut'}) | |
puts "default database" | |
p Rabbit.all | |
p Rabbit.first(:name => 'Mokha') | |
puts "-----" |
This file contains hidden or 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
source "http://rubygems.org" | |
gem "datamapper" | |
gem "sinatra" | |
gem "dm-postgres-adapter" |
This file contains hidden or 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
GEM | |
remote: http://rubygems.org/ | |
specs: | |
addressable (2.2.6) | |
bcrypt-ruby (3.0.1) | |
data_objects (0.10.7) | |
addressable (~> 2.1) | |
datamapper (1.2.0) | |
dm-aggregates (~> 1.2.0) | |
dm-constraints (~> 1.2.0) | |
dm-core (~> 1.2.0) | |
dm-migrations (~> 1.2.0) | |
dm-serializer (~> 1.2.0) | |
dm-timestamps (~> 1.2.0) | |
dm-transactions (~> 1.2.0) | |
dm-types (~> 1.2.0) | |
dm-validations (~> 1.2.0) | |
dm-aggregates (1.2.0) | |
dm-core (~> 1.2.0) | |
dm-constraints (1.2.0) | |
dm-core (~> 1.2.0) | |
dm-core (1.2.0) | |
addressable (~> 2.2.6) | |
dm-do-adapter (1.2.0) | |
data_objects (~> 0.10.6) | |
dm-core (~> 1.2.0) | |
dm-migrations (1.2.0) | |
dm-core (~> 1.2.0) | |
dm-postgres-adapter (1.2.0) | |
dm-do-adapter (~> 1.2.0) | |
do_postgres (~> 0.10.6) | |
dm-serializer (1.2.1) | |
dm-core (~> 1.2.0) | |
fastercsv (~> 1.5.4) | |
json (~> 1.6.1) | |
json_pure (~> 1.6.1) | |
multi_json (~> 1.0.3) | |
dm-timestamps (1.2.0) | |
dm-core (~> 1.2.0) | |
dm-transactions (1.2.0) | |
dm-core (~> 1.2.0) | |
dm-types (1.2.1) | |
bcrypt-ruby (~> 3.0.0) | |
dm-core (~> 1.2.0) | |
fastercsv (~> 1.5.4) | |
json (~> 1.6.1) | |
multi_json (~> 1.0.3) | |
stringex (~> 1.3.0) | |
uuidtools (~> 2.1.2) | |
dm-validations (1.2.0) | |
dm-core (~> 1.2.0) | |
do_postgres (0.10.7) | |
data_objects (= 0.10.7) | |
fastercsv (1.5.4) | |
json (1.6.4) | |
json_pure (1.6.4) | |
multi_json (1.0.4) | |
rack (1.3.5) | |
rack-protection (1.1.4) | |
rack | |
sinatra (1.3.1) | |
rack (~> 1.3, >= 1.3.4) | |
rack-protection (~> 1.1, >= 1.1.2) | |
tilt (~> 1.3, >= 1.3.3) | |
stringex (1.3.0) | |
tilt (1.3.3) | |
uuidtools (2.1.2) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
datamapper | |
dm-postgres-adapter | |
sinatra |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment