mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Change attributes default type to array to allow order to be preserved.
This commit is contained in:
@@ -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!
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user