Skip to content
Browse files

Merge pull request #9 from tilsammans/patch-1

Added example for tasks in namespaces
  • Loading branch information...
2 parents 785541b + 6b8e967 commit 6c73a1c434f0c7051adff32d492c058bb67cd7a9 @james2m committed Aug 10, 2012
Showing with 13 additions and 3 deletions.
  1. +13 −3 README.md
View
16 README.md
@@ -81,14 +81,14 @@ Usage
Seeds files are just plain old Ruby executed in your rails application environment so anything you could type into the rails console will work in your seeds.
-The seed files under db/seeds are run first in alphanumeric order followed by the ones in the db/seeds/RAILS_ENV. You can add dependencies to your seed files
-to enforce the run order. for example;
-
db/seeds/companies.seeds.rb
```ruby
Company.find_or_create_by_name('Hatch', :url => 'http://thisishatch.co.uk' )
```
+The seed files under db/seeds are run first in alphanumeric order followed by the ones in the db/seeds/RAILS_ENV. You can add dependencies to your seed files
+to enforce the run order. for example;
+
db/seeds/users.seeds.rb
```ruby
after :companies do
@@ -114,6 +114,16 @@ after :projects, :users do
end
```
+If the dependencies are in one of the environment folders, you need to namespace the parent task:
+
+db/seeds/development/users.seeds.rb
+```ruby
+after "development:companies" do
+ company = Company.find_by_name('Hatch')
+ company.users.create(:first_name => 'James', :last_name => 'McCarthy')
+end
+```
+
Contributors
============
```shell

0 comments on commit 6c73a1c

Please sign in to comment.
Something went wrong with that request. Please try again.