After an upgrade to RoR 3.4.2/8.0.2, migrating the db hits the following problem.
When running rake db:migrate, I see the following error:
... == 20151121064619 AddUploadToEntries: migrating =============================== -- add_attachment(:entries, :upload) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: (StandardError) wrong number of arguments (given 4, expected 3) /usr/local/bundle/gems/activerecord-8.0.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:338:in 'add_column' /usr/local/bundle/gems/paperclip-6.1.0/lib/paperclip/schema.rb:27:in 'block (2 levels) in Paperclip::Schema::Statements#add_attachment' ... The affected rb looks like this:
class AddUploadToEntries < ActiveRecord::Migration[8.0] def self.up add_attachment :entries, :upload end def self.down remove_attachment :entries, :upload end end However, the error message doesn't look correct because the "complaining" call appears to expect four arguments - not three as per the error message:
def add_column(table_name, column_name, type, **options) ... as in /usr/local/bundle/gems/activerecord-8.0.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:338
def add_column(table_name, column_name, type, **options) # :nodoc: type = type.to_sym if invalid_alter_table_type?(type, options) alter_table(table_name) do |definition| definition.column(column_name, type, **options) end else super end end The "offending" call sends four arguments too as is correctly reported in the error message:
... add_column(table_name, "#{attachment_name}_#{column_name}", column_type, column_options) ... ... as in /usr/local/bundle/gems/paperclip-6.1.0/lib/paperclip/schema.rb:27
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? 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) end end end So there is does not seem to be any arguments' number mismatch. I should be missing something here, surely. Can anybody help, please?