How to control the loading order of gems vs plugins in Rails

I have a plugin that must be loaded before resource_controller. The reason is that the Resourcecontroller is trying to load the ApplicationController and is dependent on the specified plugin (and will not load if the init.rb plugin is not already loaded).

The problem is that the ResourceController comes from a gem, not from a plugin.

Is there a way to load plugins before gems (from environment.rb "config.gem ...")?

+3
source share
3 answers

There is no way to download plugins in front of gems if you download them exclusively on config.gem, but this does not mean that you cannot take the resource_controller resource loading into your own hands.

As a very cruel decision, you can delete the corresponding line config.gem, and then explicitly " require" at the bottom environment.rb.

+2
source

For rails2.3x in environment.rb set your gem to lib => false and then require the gem in the after_initialize block

config.gem 'some_gem', :lib => false
config.after_initialize do
  require 'some_gem'
end

It will be done.

+1
source

Initializer.rb :

  load_gems
  load_plugins

  # pick up any gems that plugins depend on
  add_gem_load_paths
  load_gems
  check_gem_dependencies

, ... , .

resource_controller , ? "config.gem..." .

0
source

Source: https://habr.com/ru/post/1717177/


All Articles