aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/fixtures.yml4
2 files changed, 4 insertions, 2 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index a9d90f9ff7..2a2912ef7e 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Generated fixtures use the actual primary key instead of id. #4343 [Frederick Ros, Tarmo Tänav]
+
* Extend the console +helper+ method to allow you to include custom helpers. e.g:
>> helper :posts
>> helper.some_method_from_posts_helper(Post.find(1))
diff --git a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml b/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
index eb3ab81ab8..c58dd85b00 100644
--- a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
+++ b/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
@@ -1,13 +1,13 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
- id: 1
+ <%= class_name.constantize.primary_key %>: 1
<% for attribute in attributes -%>
<%= attribute.name %>: <%= attribute.default %>
<% end -%>
created_at: <%= Time.now.to_s(:db) %>
updated_at: <%= Time.now.to_s(:db) %>
two:
- id: 2
+ <%= class_name.constantize.primary_key %>: 2
<% for attribute in attributes -%>
<%= attribute.name %>: <%= attribute.default %>
<% end -%>