Permalink
Browse files

move setup step before build

The setup has to be done before the build, as it is building the engine
instances which are required for the mappers.
  • Loading branch information...
1 parent ccde375 commit 16fe13acc36a8556fa1ea122b53978bfd125dbe6 @Gibheer committed Jan 22, 2013
Showing with 9 additions and 9 deletions.
  1. +9 −9 README.md
View
@@ -81,6 +81,9 @@ end
# Create DM env
env = DataMapper::Environment.new
+# Setup db connection
+env.setup(:postgres, :uri => 'postgres://localhost/test')
+
# Define a mapper
env.build(User, :postgres) do
relation_name :users
@@ -89,9 +92,6 @@ env.build(User, :postgres) do
map :name, String, :to => :username
end
-# Setup db connection
-env.setup(:postgres, :uri => 'postgres://localhost/test')
-
# Finalize the environment
env.finalize
```
@@ -120,6 +120,9 @@ end
# Create DM env
env = DataMapper::Environment.new
+# Setup db connection
+env.setup(:postgres, :uri => 'postgres://localhost/test')
+
env.build(Order, :postgres) do
relation_name :orders
@@ -142,9 +145,6 @@ env.build(User, :postgres) do
end
end
-# Setup db connection
-env.setup(:postgres, :uri => 'postgres://localhost/test')
-
# Finalize the environment
env.finalize
@@ -181,6 +181,9 @@ end
# Create DM env
env = DataMapper::Environment.new
+# Setup db connection
+env.setup(:postgres, :uri => 'postgres://localhost/test')
+
env.build(Order, :postgres) do
key :id
end
@@ -193,9 +196,6 @@ env.build(User, :postgres) do
has 0..n, :orders, Order
end
-# Setup db connection
-env.setup(:postgres, :uri => 'postgres://localhost/test')
-
# Finalize the environment
env.finalize

0 comments on commit 16fe13a

Please sign in to comment.