lib/paperclip/schema.rb in kt-paperclip-4.4.0 vs lib/paperclip/schema.rb in kt-paperclip-5.4.0

- old
+ new

@@ -10,14 +10,11 @@ def self.included(base) ActiveRecord::ConnectionAdapters::Table.send :include, TableDefinition ActiveRecord::ConnectionAdapters::TableDefinition.send :include, TableDefinition ActiveRecord::ConnectionAdapters::AbstractAdapter.send :include, Statements - - if defined?(ActiveRecord::Migration::CommandRecorder) # Rails 3.1+ - ActiveRecord::Migration::CommandRecorder.send :include, CommandRecorder - end + ActiveRecord::Migration::CommandRecorder.send :include, CommandRecorder end module Statements def add_attachment(table_name, *attachment_names) raise ArgumentError, "Please specify attachment name in your add_attachment call in your migration." if attachment_names.empty? @@ -25,23 +22,20 @@ options = attachment_names.extract_options! attachment_names.each do |attachment_name| COLUMNS.each_pair do |column_name, column_type| column_options = options.merge(options[column_name.to_sym] || {}) - add_column(table_name, "#{attachment_name}_#{column_name}", column_type, column_options) + add_column(table_name, "#{attachment_name}_#{column_name}", column_type, **column_options) end end end def remove_attachment(table_name, *attachment_names) raise ArgumentError, "Please specify attachment name in your remove_attachment call in your migration." if attachment_names.empty? - options = attachment_names.extract_options! - attachment_names.each do |attachment_name| - COLUMNS.each_pair do |column_name, column_type| - column_options = options.merge(options[column_name.to_sym] || {}) + COLUMNS.keys.each do |column_name| remove_column(table_name, "#{attachment_name}_#{column_name}") end end end @@ -55,10 +49,10 @@ def attachment(*attachment_names) options = attachment_names.extract_options! attachment_names.each do |attachment_name| COLUMNS.each_pair do |column_name, column_type| column_options = options.merge(options[column_name.to_sym] || {}) - column("#{attachment_name}_#{column_name}", column_type, column_options) + column("#{attachment_name}_#{column_name}", column_type, **column_options) end end end def has_attached_file(*attachment_names)