We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When saving against the model retrieved by select, an error occurs and the image is updated to nil.
code
# frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org/" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem "activerecord" gem "sqlite3" gem "carrierwave" gem "rmagick" end require "active_record" require "minitest/autorun" require "logger" require 'carrierwave/orm/activerecord' ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") ActiveRecord::Base.logger = Logger.new(STDOUT) ActiveRecord::Schema.define do create_table :users, force: true do |t| t.string :avatar end end class ImageUploader < CarrierWave::Uploader::Base include CarrierWave::RMagick end class User < ActiveRecord::Base mount_uploader :avatar, ImageUploader end class BugTest < Minitest::Test def test_save_without_select User.create! assert User.last.save # test is pass end def test_save_with_select User.create! assert User.select(:id).last.save # error occurs! end end
output
Finished in 0.010423s, 191.8821 runs/s, 95.9411 assertions/s. 1) Error: BugTest#test_save_with_select: NoMethodError: undefined method `remove_previously_stored_files_after_update' for #<Object:0x00007f2757986d88> uploader.remove! if uploader.remove_previously_stored_files_after_update && !after_paths.include?(uploader.path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/local/bundle/gems/carrierwave-2.2.2/lib/carrierwave/mounter.rb:157:in `block in remove_previous' /usr/local/bundle/gems/carrierwave-2.2.2/lib/carrierwave/mounter.rb:156:in `each' /usr/local/bundle/gems/carrierwave-2.2.2/lib/carrierwave/mounter.rb:156:in `remove_previous' /usr/local/bundle/gems/carrierwave-2.2.2/lib/carrierwave/mount.rb:204:in `remove_previously_stored_profile_image_filename' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/callbacks.rb:400:in `block in make_lambda' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/callbacks.rb:261:in `block in conditional' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/callbacks.rb:599:in `block in invoke_after' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/callbacks.rb:599:in `each' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/callbacks.rb:599:in `invoke_after' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/callbacks.rb:108:in `run_callbacks' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/callbacks.rb:929:in `_run_commit_callbacks' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/transactions.rb:321:in `committed!' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:155:in `commit_records' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:304:in `block in commit_transaction' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:294:in `commit_transaction' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:345:in `block in within_new_transaction' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt' /usr/local/bundle/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/transactions.rb:350:in `with_transaction_returning_status' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/transactions.rb:298:in `save' /usr/local/bundle/gems/activerecord-7.0.3/lib/active_record/suppressor.rb:50:in `save' test.rb:48:in `test_save_with_select' 2 runs, 1 assertions, 0 failures, 1 errors, 0 skips
I would like the test test_save_with_select to go through, is this the intended behavior?
For reference, this behavior was caused by the following commit. 67800fd
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Abstract
When saving against the model retrieved by select, an error occurs and the image is updated to nil.
Step to reproduce
code
output
Question
I would like the test test_save_with_select to go through, is this the intended behavior?
For reference, this behavior was caused by the following commit.
67800fd
The text was updated successfully, but these errors were encountered: