diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-07 16:18:39 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-07 16:18:39 -0800 |
commit | 7e176a6d1248ac0a2a54c8f35846366040fda91b (patch) | |
tree | 18189a25b0379d3467854054abf4cb14f69cb483 | |
parent | 483a3cf2872a6a5d544f2c15cb60d0bf2bce036a (diff) | |
download | rails-7e176a6d1248ac0a2a54c8f35846366040fda91b.tar.gz rails-7e176a6d1248ac0a2a54c8f35846366040fda91b.tar.bz2 rails-7e176a6d1248ac0a2a54c8f35846366040fda91b.zip |
try to normalize the objects passed to column()
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index ce7a5d4156..a802868c01 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -244,12 +244,13 @@ module ActiveRecord %w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type| class_eval <<-EOV, __FILE__, __LINE__ + 1 - def #{column_type}(*args) # def string(*args) - options = args.extract_options! # options = args.extract_options! - column_names = args # column_names = args - # - column_names.each { |name| column(name, '#{column_type}', options) } # column_names.each { |name| column(name, 'string', options) } - end # end + def #{column_type}(*args) # def string(*args) + options = args.extract_options! # options = args.extract_options! + column_names = args # column_names = args + type = :'#{column_type}' + # + column_names.each { |name| column(name, type, options) } # column_names.each { |name| column(name, type, options) } + end # end EOV end @@ -463,13 +464,14 @@ module ActiveRecord def #{column_type}(*args) # def string(*args) options = args.extract_options! # options = args.extract_options! column_names = args # column_names = args + type = :'#{column_type}' # column_names.each do |name| # column_names.each do |name| - column = ColumnDefinition.new(@base, name.to_s, '#{column_type}') # column = ColumnDefinition.new(@base, name, 'string') + column = ColumnDefinition.new(@base, name.to_s, type) # column = ColumnDefinition.new(@base, name, type) if options[:limit] # if options[:limit] column.limit = options[:limit] # column.limit = options[:limit] - elsif native['#{column_type}'.to_sym].is_a?(Hash) # elsif native['string'.to_sym].is_a?(Hash) - column.limit = native['#{column_type}'.to_sym][:limit] # column.limit = native['string'.to_sym][:limit] + elsif native[type].is_a?(Hash) # elsif native[type].is_a?(Hash) + column.limit = native[type][:limit] # column.limit = native[type][:limit] end # end column.precision = options[:precision] # column.precision = options[:precision] column.scale = options[:scale] # column.scale = options[:scale] |