diff options
author | schneems <richard.schneeman@gmail.com> | 2014-06-02 10:42:48 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2014-06-02 10:43:01 -0500 |
commit | 071373857dddeefcb7a36f8838c03c5e88dd6e20 (patch) | |
tree | 53d012daa5a5ae454f332021e06233dfbc2dd3c3 | |
parent | a93f385c2b675e003afb98a57a9bd0f6377667cc (diff) | |
download | rails-071373857dddeefcb7a36f8838c03c5e88dd6e20.tar.gz rails-071373857dddeefcb7a36f8838c03c5e88dd6e20.tar.bz2 rails-071373857dddeefcb7a36f8838c03c5e88dd6e20.zip |
[ci skip] explain association behavior.
When you manually specify `id:` attribute in a fixture Rails' built in association assignment feature will no longer work. http://stackoverflow.com/questions/23985675/incorrect-association-in-fixtures
This commit raises awareness of this behavior and encourages developers to look directly at the fixture documentation.
-rw-r--r-- | guides/source/testing.md | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md index 9468f03442..c01b2e575a 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -96,6 +96,12 @@ one: category: about ``` +Note: For associations to reference one another by name, you cannot specify the `id:` + attribute on the fixtures. Rails will auto assign a primary key to be consistent between + runs. If you manually specify an `id:` attribute, this behavior will not work. For more + information on this assocation behavior please read the + [fixture api documentation](http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html). + #### ERB'in It Up ERB allows you to embed Ruby code within templates. The YAML fixture format is pre-processed with ERB when Rails loads fixtures. This allows you to use Ruby to help you generate some sample data. For example, the following code generates a thousand users: |