filestack-rails icon indicating copy to clipboard operation
filestack-rails copied to clipboard

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

Open PeteTheSadPanda opened this issue 3 years ago • 0 comments

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

PeteTheSadPanda avatar Feb 01 '21 19:02 PeteTheSadPanda