Reputation: 9455
I have a plugin that must be loaded before resource_controller. The reason is that Resourcecontroller tries to load ApplicationController and it depends on the said plugin (and will fail to load if plugin's init.rb was not loaded yet).
The problem is that ResourceController comes from a gem and not a plugin.
Is there a way to load plugins before the gems (from environment.rb's "config.gem ...")?
Upvotes: 3
Views: 2022
Reputation: 1580
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
That'll do it.
Upvotes: 1
Reputation: 1079
There's no present way to load plugins before gems if you depend exclusively on config.gem
to load them, but that doesn't mean that you can't take the loading of the resource_controller gem into your own hands.
As a very brutal solution, you can remove the relevant config.gem
line, and then explicitly 'require
' it at the bottom of environment.rb
.
Upvotes: 2
Reputation: 2712
a quick glance at the Initializer.rb code shows:
load_gems
load_plugins
# pick up any gems that plugins depend on
add_gem_load_paths
load_gems
check_gem_dependencies
If I understand it correctly, gems always comes before plugins... then some gems that the plugins require.
why not use resource_controller as a plugin, also? just don't use the "config.gem ..." and put it in the plugins directory.
Upvotes: 0