Diego
04/08/2023, 3:06 PMCompleted 500 Internal Server Error in 125ms (ActiveRecord: 62.2ms | Allocations: 20727)
ArgumentError (wrong number of arguments (given 2, expected 1)):
Relevant gems:
gem 'solidus', '= 2.11.17'
gem 'cloudinary', '~> 1.1.7', require: false
gem 'activestorage-cloudinary-service'
gem 'open_solidus_cloudinary', github: 'Berlimioz/open_solidus_cloudinary'
Any ideas what this error might be caused by or how to debug?kennyadsl
Diego
04/11/2023, 12:04 PMkennyadsl
open_solidus_cloudinary
(which I’m not familiar with), because it’s very old and I don’t think it takes into account activestoragekennyadsl
activestorage-cloudinary-service
, seems like they do similar things, isn’t it?Diego
04/11/2023, 1:30 PMactivestorage-cloudinary-service
gem (if I remove it, get a “missing service adapter” error).
Could it be that open_solidus_cloudinary
is not compatible with ruby 3.0.0?
Do you happen to know if there’s any documentation about integrating Cloudinary?
BTW, this is the full error message in the logs:
ArgumentError (wrong number of arguments (given 2, expected 1)):
.rbenv/versions/3.0.0/lib/ruby/3.0.0/fileutils.rb:206:in `mkdir_p'
carrierwave (0.11.2) lib/carrierwave/sanitized_file.rb:294:in `mkdir!'
carrierwave (0.11.2) lib/carrierwave/sanitized_file.rb:211:in `copy_to'
carrierwave (0.11.2) lib/carrierwave/uploader/cache.rb:143:in `block in cache!'
carrierwave (0.11.2) lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
carrierwave (0.11.2) lib/carrierwave/uploader/cache.rb:134:in `cache!'
cloudinary (1.1.7) lib/cloudinary/carrier_wave/preloaded.rb:19:in `cache!'
carrierwave (0.11.2) lib/carrierwave/mount.rb:329:in `cache'
carrierwave (0.11.2) lib/carrierwave/mount.rb:163:in `attachment='
carrierwave (0.11.2) lib/carrierwave/orm/activerecord.rb:39:in `attachment='
solidus_core (2.11.17) app/models/concerns/spree/active_storage_adapter.rb:73:in `block (2 levels) in override_writer'
activemodel (6.1.7.3) lib/active_model/attribute_assignment.rb:49:in `public_send'
activemodel (6.1.7.3) lib/active_model/attribute_assignment.rb:49:in `_assign_attribute'
activerecord (6.1.7.3) lib/active_record/attribute_assignment.rb:21:in `block in _assign_attributes'
activerecord (6.1.7.3) lib/active_record/attribute_assignment.rb:13:in `each'
activerecord (6.1.7.3) lib/active_record/attribute_assignment.rb:13:in `_assign_attributes'
activemodel (6.1.7.3) lib/active_model/attribute_assignment.rb:34:in `assign_attributes'
solidus_backend (2.11.17) app/controllers/spree/admin/resource_controller.rb:59:in `create'
actionpack (6.1.7.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.1.7.3) lib/abstract_controller/base.rb:228:in `process_action'
actionpack (6.1.7.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.1.7.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.1.7.3) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
actiontext (6.1.7.3) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (6.1.7.3) lib/action_text/engine.rb:59:in `block (4 levels) in <class:Engine>'
activesupport (6.1.7.3) lib/active_support/callbacks.rb:126:in `instance_exec'
activesupport (6.1.7.3) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
activesupport (6.1.7.3) lib/active_support/callbacks.rb:137:in `run_callbacks'
actionpack (6.1.7.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.1.7.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.1.7.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (6.1.7.3) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.7.3) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.7.3) lib/active_support/notifications.rb:203:in `instrument'
actionpack (6.1.7.3) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
actionpack (6.1.7.3) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
activerecord (6.1.7.3) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.1.7.3) lib/abstract_controller/base.rb:165:in `process'
actionview (6.1.7.3) lib/action_view/rendering.rb:39:in `process'
actionpack (6.1.7.3) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.1.7.3) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.1.7.3) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.1.7.3) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.1.7.3) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.7.3) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.7.3) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.7.3) lib/action_dispatch/routing/route_set.rb:842:in `call'
railties (6.1.7.3) lib/rails/engine.rb:539:in `call'
railties (6.1.7.3) lib/rails/railtie.rb:207:in `public_send'
railties (6.1.7.3) lib/rails/railtie.rb:207:in `method_missing'
actionpack (6.1.7.3) lib/action_dispatch/routing/mapper.rb:20:in `block in <class:Constraints>'
actionpack (6.1.7.3) lib/action_dispatch/routing/mapper.rb:49:in `serve'
actionpack (6.1.7.3) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.7.3) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.7.3) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.7.3) lib/action_dispatch/routing/route_set.rb:842:in `call'
bullet (7.0.7) lib/bullet/rack.rb:17:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.6.4) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.6.4) lib/rack/etag.rb:27:in `call'
rack (2.2.6.4) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.6.4) lib/rack/head.rb:12:in `call'
actionpack (6.1.7.3) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
actionpack (6.1.7.3) lib/action_dispatch/http/content_security_policy.rb:19:in `call'
rack (2.2.6.4) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.6.4) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/cookies.rb:697:in `call'
activerecord (6.1.7.3) lib/active_record/migration.rb:601:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.7.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.7.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.2.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.1.7.3) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.7.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.1.7.3) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (6.1.7.3) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (6.1.7.3) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (6.1.7.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.5.1) lib/request_store/middleware.rb:19:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.6.4) lib/rack/method_override.rb:24:in `call'
rack (2.2.6.4) lib/rack/runtime.rb:22:in `call'
activesupport (6.1.7.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/static.rb:24:in `call'
rack (2.2.6.4) lib/rack/sendfile.rb:110:in `call'
actionpack (6.1.7.3) lib/action_dispatch/middleware/host_authorization.rb:148:in `call'
webpacker (5.4.4) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
rack-proxy (0.7.6) lib/rack/proxy.rb:87:in `call'
railties (6.1.7.3) lib/rails/engine.rb:539:in `call'
puma (3.12.6) lib/puma/configuration.rb:227:in `call'
puma (3.12.6) lib/puma/server.rb:706:in `handle_request'
puma (3.12.6) lib/puma/server.rb:476:in `process_client'
puma (3.12.6) lib/puma/server.rb:334:in `block in run'
puma (3.12.6) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
kennyadsl
kennyadsl
Diego
04/11/2023, 5:27 PMDiego
04/30/2023, 10:47 AMopen_solidus_cloudinary
gem, which I used before, the images were uploaded as mount_uploader :attachment, CloudinaryUploader, :mount_on => :attachment_file_name
.
This is my first time migrating live DB data, so I am quite freaked out. 😬
Could you please let me know if the following approach makes sense?
1. I created a decorator (app/decorators/image_decorator.rb
):
Spree::Image.class_eval do
has_one_attached :as_attachment
end
2. I created rake tasks (lib/tasks/migrate_images_to_activestorage.rb
):
namespace :active_storage do
desc "Migrate images to use Active Storage"
task migrate_images: :environment do
puts '*' * 50
puts "Start migrating #{Spree::Image.count} images..."
Spree::Image.find_each do |image|
next if !image.attachment.present? || image.as_attachment.attached?
picture = image.attachment
picture.cache_stored_file!
file = picture.sanitized_file.file
content_type = "image/png"
filename = picture.filename
image.as_attachment.attach(io: file, content_type: content_type, filename: filename)
image.attachment.remove!
image.save
end
puts "Completed migrating #{Spree::Image.count} profiles..."
puts '*' * 50
end
desc 'Rename as_attachment to attachment'
task rename_as_attachment_to_attachment: :environment do
sql = <<-SQL
UPDATE active_storage_attachments
SET name = 'attachment'
WHERE name = 'as_attachment';
SQL
ActiveRecord::Base.connection.execute(sql)
end
end
3. I deploy that and run heroku run rake active_storage:migrate_images
4. I delete the image_decorator.rb
5. I deploy again and run heroku run rake active_storage:rename_as_attachment_to_attachment
Thanks for your feedback.kennyadsl
Diego
05/02/2023, 11:22 AMkennyadsl
kennyadsl
Diego
05/02/2023, 11:25 AM