mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Change attributes default type to array to allow order to be preserved.
This commit is contained in:
parent
c90419d4f4
commit
10fd021789
7 changed files with 8 additions and 7 deletions
|
@ -3,7 +3,7 @@ require 'generators/active_record'
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
module Generators
|
module Generators
|
||||||
class MigrationGenerator < Base
|
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
|
def create_migration_file
|
||||||
set_local_assigns!
|
set_local_assigns!
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'generators/active_record'
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
module Generators
|
module Generators
|
||||||
class ModelGenerator < Base
|
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
|
check_class_collision
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Erb
|
||||||
class ScaffoldGenerator < Base
|
class ScaffoldGenerator < Base
|
||||||
include Rails::Generators::ScaffoldBase
|
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 :form, :type => :boolean
|
||||||
class_option :layout, :type => :boolean
|
class_option :layout, :type => :boolean
|
||||||
|
|
|
@ -41,7 +41,8 @@ module Rails
|
||||||
# Convert attributes hash into an array with GeneratedAttribute objects.
|
# Convert attributes hash into an array with GeneratedAttribute objects.
|
||||||
#
|
#
|
||||||
def parse_attributes! #:nodoc:
|
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)
|
Rails::Generators::GeneratedAttribute.new(name, type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Rails
|
module Rails
|
||||||
module Generators
|
module Generators
|
||||||
class MigrationGenerator < NamedBase #metagenerator
|
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
|
hook_for :orm, :required => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Rails
|
module Rails
|
||||||
module Generators
|
module Generators
|
||||||
class ModelGenerator < NamedBase #metagenerator
|
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
|
hook_for :orm, :required => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'generators/test_unit'
|
||||||
module TestUnit
|
module TestUnit
|
||||||
module Generators
|
module Generators
|
||||||
class ModelGenerator < Base
|
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
|
class_option :fixture, :type => :boolean
|
||||||
|
|
||||||
check_class_collision :suffix => "Test"
|
check_class_collision :suffix => "Test"
|
||||||
|
|
Loading…
Reference in a new issue