You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a console:
c= Core::CoreXls.new
c.excel = File.open '/path/to/file'
c.save
Expected behavior
Model is saved and attachment uploaded to s3
Actual behavior
An exception is raised
/Users/saten/.rvm/gems/ruby-3.2.2/gems/activerecord-7.0.8/lib/active_record/relation.rb:464:in `update_all': wrong number of arguments (given 2, expected 1) (ArgumentError)
Additional context
It seems like update_all is being called in a pre Rails 3 way like Model.update_all(modifications_hash,finder_hash) as opposed to Model.where(finder_hash).update_all(modifications_hash)
The text was updated successfully, but these errors were encountered:
Can't save a model after attaching a file to it
After adding an attachment to a model, and setting a file it can't be saved.
Saving the model works fine unless the attachment is set or modified
To Reproduce
Create a model like this on rails 7.0.8
class Core::CoreXls < ApplicationRecord
self.table_name= 'core_xlses'
#attr_accessor :excel_file_name,:excel_file_size,:excel_updated_at,:excel_created_at
has_attached_file :excel,
:url => ":s3_eu_url",
:path => "system/:class/:attachment/:id/:style/:basename.:extension",
:storage => :s3,
:bucket=>S3_CONFIG[::Rails.env]["bucket"],
:s3_protocol=>"https",
:s3_credentials => {
:access_key_id => S3_CONFIG[::Rails.env]["access_key_id"],
:secret_access_key => S3_CONFIG[::Rails.env]["secret_access_key"]
}
do_not_validate_attachment_file_type :excel
end
In a console:
c= Core::CoreXls.new
c.excel = File.open '/path/to/file'
c.save
Expected behavior
Model is saved and attachment uploaded to s3
Actual behavior
An exception is raised
/Users/saten/.rvm/gems/ruby-3.2.2/gems/activerecord-7.0.8/lib/active_record/relation.rb:464:in `update_all': wrong number of arguments (given 2, expected 1) (ArgumentError)
Additional context
It seems like update_all is being called in a pre Rails 3 way like Model.update_all(modifications_hash,finder_hash) as opposed to Model.where(finder_hash).update_all(modifications_hash)
The text was updated successfully, but these errors were encountered: