Skip to content
New issue

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

Mechanism by which Filestack helpers are included in ActionController::Base is resulting in deprecation warnings which will soon be errors in Rails #238

Open
PeteTheSadPanda opened this issue Feb 1, 2021 · 0 comments

Comments

@PeteTheSadPanda
Copy link

PeteTheSadPanda commented Feb 1, 2021

This is observed as of the latest filestack-rails release i.e. 5.4.1 and the version of Rails in which this was discovered was 6.0.3.4.

The deprecation warning is as follows:


DEPRECATION WARNING: Initialization autoloaded the constants FilestackRails::ApplicationHelper, FilestackRails::FormHelper,...

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload FilestackRails::ApplicationHelper, for example,
the expected changes won't be reflected in that stale Module object.

Currently the FilestackRails Engine is injecting its helpers in by using a pattern which will in future versions of Rails will result in a hard error instead of a deprecation warning. The following lines are the culprits:

module FilestackRails
class Engine < ::Rails::Engine
config.filestack_rails = FilestackRails::Configuration.new
isolate_namespace FilestackRails

initializer 'filestack_rails.action_controller' do |app|       #<- this block
  ActiveSupport.on_load(:action_controller) do
    ::ActionController::Base.helper(FilestackRails::ApplicationHelper)
  end
end

initializer "filestack_rails.form_builder" do #<- this block
  ActionView::Helpers::FormBuilder.send(:include, FilestackRails::FormHelper)
end

end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant