From ac8469d233821899283bcb7e6b0cd8d4203ffb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 12 Mar 2012 20:10:40 -0300 Subject: Use the attributes hash explicitly --- .../test_unit/scaffold/scaffold_generator.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb') diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index 760917896f..4c07baae36 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -17,9 +17,22 @@ module TestUnit private - def accessible_attributes - attributes.reject(&:reference?).map {|a| "\"#{a.name}\"" }.sort.join(', ') - end + def resource_attributes + key_value singular_table_name, "{ #{attributes_hash} }" + end + + def attributes_hash + return if accessible_attributes.empty? + + accessible_attributes.map do |a| + name = a.name + "#{name}: @#{singular_table_name}.#{name}" + end.sort.join(', ') + end + + def accessible_attributes + attributes.reject(&:reference?) + end end end end -- cgit v1.2.3