Skip to content

Commit

Permalink
Merge pull request #9 from tilsammans/patch-1
Browse files Browse the repository at this point in the history
Added example for tasks in namespaces
  • Loading branch information
James McCarthy committed Aug 10, 2012
2 parents 785541b + 6b8e967 commit 6c73a1c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6c73a1c

Please sign in to comment.