amatsuda/jb

Deprecation warning with generators in Rails 6.0.2

peterxjang opened this issue · 1 comments

In Rails 6.0.2, running any rails generate commands with the jb gem installed results in this deprecation warning:

Deprecation warning: Expected string default value for '--jb'; got true (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.

I believe this issue is coming from the scaffold generator controller: https://github.com/amatsuda/jb/blob/master/lib/generators/rails/scaffold_controller_generator.rb. For some reason Rails 6.0.2 is expecting a string value here. This issue did not occur on Rails 6.0.1 or any other prior versions as far as I know.

I was able to eliminate the deprecation warning by adding the line config.generators.jb = "true" in my config/application.rb file, which is providing a string value as opposed to a boolean. However, I'm not sure if that's the correct approach, setting it to "true" or "false" didn't seem to have an effect on the generator functionality, although I didn't test every scenario. Any thoughts are appreciated, thanks!

@peterxjang Thank you so much for letting me know the issue!
What was happening is that Thor 1.0 introduced a stricter type checking for default value via rails/thor@7d199c0
and it caused this warning even on existing Rails apps.

I just fixed the issue via 3fa34a2 and published version 0.7.1 gem with this fix.