diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 0678a52f82..cb0694eda2 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1857,7 +1857,7 @@ module ActiveRecord hm_options[k] = options[k] if options.key? k end - has_many name, scope, hm_options, &extension + has_many name, scope, **hm_options, &extension _reflections[name.to_s].parent_reflection = habtm_reflection end end 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 aedd8119ef..b6f064ab6c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -139,7 +139,8 @@ module ActiveRecord def add_to(table) columns.each do |column_options| - table.column(*column_options) + kwargs = column_options.extract_options! + table.column(*column_options, **kwargs) end if index @@ -199,7 +200,7 @@ module ActiveRecord # Appends a primary key definition to the table definition. # Can be called multiple times, but this is probably not a good idea. def primary_key(name, type = :primary_key, **options) - column(name, type, options.merge(primary_key: true)) + column(name, type, **options.merge(primary_key: true)) end ## @@ -226,7 +227,7 @@ module ActiveRecord module_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{column_type}(*names, **options) raise ArgumentError, "Missing column name(s) for #{column_type}" if names.empty? - names.each { |name| column(name, :#{column_type}, options) } + names.each { |name| column(name, :#{column_type}, **options) } end RUBY end @@ -375,7 +376,7 @@ module ActiveRecord index_options = options.delete(:index) index(name, index_options.is_a?(Hash) ? index_options : {}) if index_options - @columns_hash[name] = new_column_definition(name, type, options) + @columns_hash[name] = new_column_definition(name, type, **options) self end @@ -408,8 +409,8 @@ module ActiveRecord options[:precision] = 6 end - column(:created_at, :datetime, options) - column(:updated_at, :datetime, options) + column(:created_at, :datetime, **options) + column(:updated_at, :datetime, **options) end # Adds a reference. @@ -479,7 +480,7 @@ module ActiveRecord def add_column(name, type, options) name = name.to_s type = type.to_sym - @adds << AddColumnDefinition.new(@td.new_column_definition(name, type, options)) + @adds << AddColumnDefinition.new(@td.new_column_definition(name, type, **options)) end end diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 88367c79a1..7d9d7c2be4 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -301,7 +301,7 @@ module ActiveRecord if pk.is_a?(Array) td.primary_keys pk else - td.primary_key pk, id, options + td.primary_key pk, id, **options end end @@ -785,7 +785,7 @@ module ActiveRecord # # For more information see the {"Transactional Migrations" section}[rdoc-ref:Migration]. def add_index(table_name, column_name, options = {}) - index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, options) + index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, **options) execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{index_columns})#{index_options}" end @@ -1255,7 +1255,7 @@ module ActiveRecord # the PostgreSQL adapter for supporting operator classes. def add_options_for_index_columns(quoted_columns, **options) if supports_index_sort_order? - quoted_columns = add_index_sort_order(quoted_columns, options) + quoted_columns = add_index_sort_order(quoted_columns, **options) end quoted_columns @@ -1265,7 +1265,7 @@ module ActiveRecord return [column_names] if column_names.is_a?(String) quoted_columns = Hash[column_names.map { |name| [name.to_sym, quote_column_name(name).dup] }] - add_options_for_index_columns(quoted_columns, options).values + add_options_for_index_columns(quoted_columns, **options).values end def index_name_for_remove(table_name, options = {}) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb index 53ce8df491..7893ec85d6 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb @@ -146,7 +146,7 @@ module ActiveRecord class SavepointTransaction < Transaction def initialize(connection, savepoint_name, parent_transaction, **options) - super(connection, options) + super(connection, **options) parent_transaction.state.add_child(@state) diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index f4847eb6c0..0409423681 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -388,7 +388,7 @@ module ActiveRecord def copy_table(from, to, options = {}) from_primary_key = primary_key(from) options[:id] = false - create_table(to, options) do |definition| + create_table(to, **options) do |definition| @definition = definition if from_primary_key.is_a?(Array) @definition.primary_keys from_primary_key diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb index 6fecb06897..939dbcecf4 100644 --- a/activerecord/lib/active_record/store.rb +++ b/activerecord/lib/active_record/store.rb @@ -103,7 +103,7 @@ module ActiveRecord module ClassMethods def store(store_attribute, options = {}) serialize store_attribute, IndifferentCoder.new(store_attribute, options[:coder]) - store_accessor(store_attribute, options[:accessors], options.slice(:prefix, :suffix)) if options.has_key? :accessors + store_accessor(store_attribute, options[:accessors], **options.slice(:prefix, :suffix)) if options.has_key? :accessors end def store_accessor(store_attribute, *keys, prefix: nil, suffix: nil) diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 5113e08e8e..24ac53103b 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -208,8 +208,8 @@ module ActiveRecord # Note that "TRUNCATE" is also a MySQL DDL statement! module ClassMethods # See the ConnectionAdapters::DatabaseStatements#transaction API docs. - def transaction(options = {}, &block) - connection.transaction(options, &block) + def transaction(**options, &block) + connection.transaction(**options, &block) end def before_commit(*args, &block) # :nodoc: