diff --git a/railties/lib/generators/active_record/migration/migration_generator.rb b/railties/lib/generators/active_record/migration/migration_generator.rb index 95cc34ba42..7939977f72 100644 --- a/railties/lib/generators/active_record/migration/migration_generator.rb +++ b/railties/lib/generators/active_record/migration/migration_generator.rb @@ -3,7 +3,7 @@ require 'generators/active_record' module ActiveRecord module Generators class MigrationGenerator < Base - argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" + argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" def create_migration_file set_local_assigns! diff --git a/railties/lib/generators/active_record/model/model_generator.rb b/railties/lib/generators/active_record/model/model_generator.rb index d337ca4eec..54187aede0 100644 --- a/railties/lib/generators/active_record/model/model_generator.rb +++ b/railties/lib/generators/active_record/model/model_generator.rb @@ -3,7 +3,7 @@ require 'generators/active_record' module ActiveRecord module Generators class ModelGenerator < Base - argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" + argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" check_class_collision diff --git a/railties/lib/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/generators/erb/scaffold/scaffold_generator.rb index 946c5a0abc..955f22192a 100644 --- a/railties/lib/generators/erb/scaffold/scaffold_generator.rb +++ b/railties/lib/generators/erb/scaffold/scaffold_generator.rb @@ -5,7 +5,7 @@ module Erb class ScaffoldGenerator < Base include Rails::Generators::ScaffoldBase - argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" + argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" class_option :form, :type => :boolean class_option :layout, :type => :boolean diff --git a/railties/lib/generators/named_base.rb b/railties/lib/generators/named_base.rb index 0d399c876c..699b8ed651 100644 --- a/railties/lib/generators/named_base.rb +++ b/railties/lib/generators/named_base.rb @@ -41,7 +41,8 @@ module Rails # Convert attributes hash into an array with GeneratedAttribute objects. # def parse_attributes! #:nodoc: - self.attributes = (attributes || {}).map do |name, type| + self.attributes = (attributes || []).map do |key_value| + name, type = key_value.split(':') Rails::Generators::GeneratedAttribute.new(name, type) end end diff --git a/railties/lib/generators/rails/migration/migration_generator.rb b/railties/lib/generators/rails/migration/migration_generator.rb index 4e2db5e441..39fa5b63b1 100644 --- a/railties/lib/generators/rails/migration/migration_generator.rb +++ b/railties/lib/generators/rails/migration/migration_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class MigrationGenerator < NamedBase #metagenerator - argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" + argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" hook_for :orm, :required => true end end diff --git a/railties/lib/generators/rails/model/model_generator.rb b/railties/lib/generators/rails/model/model_generator.rb index 189f072365..629d5eed3f 100644 --- a/railties/lib/generators/rails/model/model_generator.rb +++ b/railties/lib/generators/rails/model/model_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class ModelGenerator < NamedBase #metagenerator - argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" + argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" hook_for :orm, :required => true end end diff --git a/railties/lib/generators/test_unit/model/model_generator.rb b/railties/lib/generators/test_unit/model/model_generator.rb index 92fd75a2d5..469306e6c5 100644 --- a/railties/lib/generators/test_unit/model/model_generator.rb +++ b/railties/lib/generators/test_unit/model/model_generator.rb @@ -3,7 +3,7 @@ require 'generators/test_unit' module TestUnit module Generators class ModelGenerator < Base - argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" + argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" class_option :fixture, :type => :boolean check_class_collision :suffix => "Test"