uploadcare / uploadcare-rails

Rails API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.

Home Page:https://uploadcare.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[dry-configurable] warnings

jidylle opened this issue · comments

Question

Hi,
We added the uploadcare-ruby-3.2.0 gem and now we have several warnings each time we started our app.

"vendor/bundle/gems/uploadcare-ruby-3.2.0/lib/uploadcare.rb:29:in <top (required)>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version Provide a default:` keyword argument instead"

May be a way to fix it : https://hanamimastery.com/episodes/5-configure-anything-with-dry-configurable
(search keyword "constructor" in the page)

How to fix it ?
Thanks

Hi, @jidylle!

Thanks for the suggestion!

The warning does not affect functionality, so you can simply disable it by setting parameters in your project:

Dry::Configurable.warn_on_setting_constructor_block false
Dry::Configurable.warn_on_setting_positional_default false

source https://github.com/dry-rb/dry-configurable/blob/master/CHANGELOG.md

Probably we will fix it in next major versions.
Thanks!

Hey, @jidylle!

I guess the good place for these lines is a initializer. Have you tried to add them in an existing or new initializer file (in Rails apps it usually located in config/initializers/<your_filename>.rb - smth like config/initializers/dry_configurable.rb)?

Have a nice day!

Hi, @jidylle !

Sorry for late reply! Yes, you are right that initializer won't work because they are loaded after gems (uploadcare gem).
Another hack you can do is placing these two strings in the config/application.rb file.

But you should place them along with require 'dry-configurable' before all gems load string.
See the pic

dry-conf-hack

I also believe that you can move these lines (8-11) to a separate file and require this new file in the config/application.rb for more readability and decreasing size of the config/application.rb file.

Have a nice day!