mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Address "warning: in `column': the last argument was passed as a single Hash"
This commit is contained in:
parent
6cb176cddf
commit
b57ca840a6
3 changed files with 12 additions and 11 deletions
|
@ -208,7 +208,7 @@ module ActiveRecord
|
|||
|
||||
##
|
||||
# :method: column
|
||||
# :call-seq: column(name, type, options = {})
|
||||
# :call-seq: column(name, type, **options)
|
||||
#
|
||||
# Appends a column or columns of a specified type.
|
||||
#
|
||||
|
@ -364,7 +364,7 @@ module ActiveRecord
|
|||
# t.references :tagger, polymorphic: true
|
||||
# t.references :taggable, polymorphic: { default: 'Photo' }, index: false
|
||||
# end
|
||||
def column(name, type, options = {})
|
||||
def column(name, type, **options)
|
||||
name = name.to_s
|
||||
type = type.to_sym if type
|
||||
options = options.dup
|
||||
|
@ -541,7 +541,7 @@ module ActiveRecord
|
|||
# t.column(:name, :string)
|
||||
#
|
||||
# See TableDefinition#column for details of the options you can use.
|
||||
def column(column_name, type, options = {})
|
||||
def column(column_name, type, **options)
|
||||
index_options = options.delete(:index)
|
||||
@base.add_column(name, column_name, type, options)
|
||||
index(column_name, index_options.is_a?(Hash) ? index_options : {}) if index_options
|
||||
|
|
|
@ -584,7 +584,7 @@ module ActiveRecord
|
|||
# # Defines a column with a database-specific type.
|
||||
# add_column(:shapes, :triangle, 'polygon')
|
||||
# # ALTER TABLE "shapes" ADD "triangle" polygon
|
||||
def add_column(table_name, column_name, type, options = {})
|
||||
def add_column(table_name, column_name, type, **options)
|
||||
at = create_alter_table table_name
|
||||
at.add_column(column_name, type, options)
|
||||
execute schema_creation.accept at
|
||||
|
|
|
@ -94,17 +94,18 @@ ActiveRecord::Schema.define do
|
|||
end
|
||||
|
||||
create_table :books, id: :integer, force: true do |t|
|
||||
default_zero = { default: 0 }
|
||||
t.references :author
|
||||
t.string :format
|
||||
t.column :name, :string
|
||||
t.column :status, :integer, default: 0
|
||||
t.column :read_status, :integer, default: 0
|
||||
t.column :status, :integer, **default_zero
|
||||
t.column :read_status, :integer, **default_zero
|
||||
t.column :nullable_status, :integer
|
||||
t.column :language, :integer, default: 0
|
||||
t.column :author_visibility, :integer, default: 0
|
||||
t.column :illustrator_visibility, :integer, default: 0
|
||||
t.column :font_size, :integer, default: 0
|
||||
t.column :difficulty, :integer, default: 0
|
||||
t.column :language, :integer, **default_zero
|
||||
t.column :author_visibility, :integer, **default_zero
|
||||
t.column :illustrator_visibility, :integer, **default_zero
|
||||
t.column :font_size, :integer, **default_zero
|
||||
t.column :difficulty, :integer, **default_zero
|
||||
t.column :cover, :string, default: "hard"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue