Skip to content

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

@PeteTheSadPanda

Description

@PeteTheSadPanda

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions