Skip to content
Browse files

Added example for tasks in namespaces

  • Loading branch information...
1 parent 785541b commit 6b8e9678bfe2e3a276d4c48a7a5a1b1470285743 @tilsammans tilsammans committed
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 6b8e967

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