From 4a487f94b9812964e644716f301ab287dea8cddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 9 Dec 2012 14:34:26 -0300 Subject: Make references and belongs_to attributes to generate the _id column in fixtures --- railties/lib/rails/generators/test_unit/model/templates/fixtures.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails/generators/test_unit/model/templates/fixtures.yml') diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml index 5c8780aa64..71f4f99d02 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml @@ -3,12 +3,12 @@ <% unless attributes.empty? -%> one: <% attributes.each do |attribute| -%> - <%= attribute.name %>: <%= attribute.default %> + <%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %> <% end -%> two: <% attributes.each do |attribute| -%> - <%= attribute.name %>: <%= attribute.default %> + <%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %> <% end -%> <% else -%> # This model initially had no columns defined. If you add columns to the -- cgit v1.2.3 From b05b77be9caf2617f35d93786d9b40c17e07bf64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 9 Dec 2012 15:20:32 -0300 Subject: Deal with polymorphic attributes correctly in the generators --- railties/lib/rails/generators/test_unit/model/templates/fixtures.yml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/lib/rails/generators/test_unit/model/templates/fixtures.yml') diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml index 71f4f99d02..7f29932ceb 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml @@ -4,11 +4,13 @@ one: <% attributes.each do |attribute| -%> <%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %> + <%= "#{attribute.name}_type: #{attribute.human_name}" if attribute.polymorphic? %> <% end -%> two: <% attributes.each do |attribute| -%> <%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %> + <%= "#{attribute.name}_type: #{attribute.human_name}" if attribute.polymorphic? %> <% end -%> <% else -%> # This model initially had no columns defined. If you add columns to the -- cgit v1.2.3 From 95ccbd847da149b194cbf423e04e3d19a812dce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 9 Dec 2012 17:01:03 -0300 Subject: Add GeneratedAttribute#column_name to get the name of the column in the database --- railties/lib/rails/generators/test_unit/model/templates/fixtures.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails/generators/test_unit/model/templates/fixtures.yml') diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml index 7f29932ceb..b2bcaf63be 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml @@ -3,13 +3,13 @@ <% unless attributes.empty? -%> one: <% attributes.each do |attribute| -%> - <%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %> + <%= attribute.column_name %>: <%= attribute.default %> <%= "#{attribute.name}_type: #{attribute.human_name}" if attribute.polymorphic? %> <% end -%> two: <% attributes.each do |attribute| -%> - <%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %> + <%= attribute.column_name %>: <%= attribute.default %> <%= "#{attribute.name}_type: #{attribute.human_name}" if attribute.polymorphic? %> <% end -%> <% else -%> -- cgit v1.2.3