提交 10fd0217 编写于 作者: J José Valim

Change attributes default type to array to allow order to be preserved.

上级 c90419d4
......@@ -3,7 +3,7 @@
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!
......
......@@ -3,7 +3,7 @@
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
......
......@@ -5,7 +5,7 @@ module Generators
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
......
......@@ -41,7 +41,8 @@ def assign_names!(given_name) #:nodoc:
# 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
......
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
......
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
......
......@@ -3,7 +3,7 @@
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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册