I recently switched from the gem version of resources_controller
to a plugin
as the gem
version relied on git
.
Inside the vendor/plugins/plugin/lib/plugin.rb
file, the Railtie
is as follows:
module Ardes
module ResourcesController
class Railtie < Rails::Railtie
initializer 'ardes.resources_controller' do
ActiveSupport.on_load(:action_controller) do
extend Ardes::ResourcesController
include Ardes::ResourcesController::RequestPathIntrospection
end
ActiveSupport.on_load(:active_record) do
include Ardes::ActiveRecord::Saved
end
end
end
end
end
I've added a require 'resources_controller'
in one of my initializers and it's properly loading this file. The problem is that although the Railtie
is evaluated (a puts
in the class block will hit), it never seems to actually call the initializer block itself. This is important of course as this is where it extends ActionController
to include the resources_controller_for
method.
This question is appears to have come up here and here. Though in both cases they found other ways around the problem and no direct answer was given for why the block wasn't being called.
From what I can tell in the Rails docs you can name your initializer block anything you'd like and it should run. I don't think it matters, but I first noticed the problem when running in production rails s -e production
though I believe the same problem exists in development mode.
What may be going on?
For reference, full plugin is here: https://github.com/ianwhite/resources_controller