config.reload_plugins = true is not picking up all the changes

Currently I am tweaking resources_controller plugin to fit to our need, I changed all the references of require to require_dependency so that Rails will take care of whether to use require or load dependening on the environment. I heard that even in development environment, rails is not going to reload the plugins even though I use require_dependency unless I set config.reload_plugins = true.

At first, I was very much excited, to see that Rails is in deed reloading the files (Constants) and this is a very good news, because I can see the changes I make to the plugins without restarting the server everytime. Unfortunately my excitement didnot last very long when I see that Rails is reloading all the files under the lib folder of the plugin except the init.rb and my first reference to the Plugin. For instance, resources_controller defined the following in init.rb:

require_dependency 'ardes/resources_controller' ActionController::Base.send :extend, Ardes::ResourcesController

Andres::ResourcesController (Module) resides in resources_controller.rb under lib/andres/ folder. Apart from this file (I call it Plugin Core file) and init.rb, there are bunch of other files under lib/andres/resources_controller folder. Where appropriate I included require_dependency instead of require. For some reason (that I can't figure out yet) Rails is reloading all the other files except init.rb and resources_controller.rb

If someone can shed light I would appreciate it.

<b>Related Information:</b> Resources_Controller Plugin Folder Structure: vendor/plugins/resources_controller/init.rb vendor/plugins/resources_controller/andres/resources_controller.rb vendor/plugins/resources_controller/andres/resources_controller/ actions.rb vendor/plugins/resources_controller/andres/resources_controller/ helper.rb vendor/plugins/resources_controller/andres/resources_controller/ named_route_helper.rb vendor/plugins/resources_controller/andres/resources_controller/ singleton_actions.rb vendor/plugins/resources_controller/andres/resources_controller/ specification.rb

Contents of resources_controller.rb (Plugin Core File) require_dependency 'ardes/resources_controller/specification' require_dependency 'ardes/resources_controller/include_actions' require_dependency 'ardes/resources_controller/actions' require_dependency 'ardes/resources_controller/singleton_actions' require_dependency 'ardes/resources_controller/helper' require_dependency 'ardes/resources_controller/named_route_helper'

module Ardes#:nodoc:   module ResourcesController     mattr_accessor :actions, :singleton_actions     self.actions = Ardes::ResourcesController::Actions     self.singleton_actions = Ardes::ResourcesController::SingletonActions

    def self.extended(base)       base.class_eval do         class_inheritable_reader :resource_specification_map         write_inheritable_attribute(:resource_specification_map, {})       end

    end

    def resources_controller_for(name, options = {}, &block)       options.assert_valid_keys (:class, :source, :singleton, :actions, :in, :find, :load_enclosing, :route, :segment, :as, :only, :except)       when_options = {:only => options.delete(:only), :except => options.delete(:except)}

      #unless included_modules.include? Ardes::ResourcesController::InstanceMethods         class_inheritable_reader :specifications, :route_name         hide_action :specifications, :route_name         extend Ardes::ResourcesController::ClassMethods         include Ardes::ResourcesController::InstanceMethods         helper Ardes::ResourcesController::Helper         include Ardes::ResourcesController::NamedRouteHelper       #end

      before_filter(:load_enclosing_resources, when_options) unless load_enclosing_resources_filter_exists?

      #before_filter :some_action

      before_filter :load_resources, :only => [:index]       before_filter :load_resource, :only => [:show, :edit, :update, :destroy]       before_filter :build_resource, :only => [:new, :create]

      write_inheritable_attribute(:specifications, )       specifications << '*' unless options.delete(:load_enclosing) == false

      unless (actions = options.delete(:actions)) == false         actions ||= options[:singleton] ? Ardes::ResourcesController.singleton_actions : Ardes::ResourcesController.actions         include_actions actions, when_options       end

      route = (options.delete(:route) || name).to_s       name = options[:singleton] ? name.to_s : name.to_s.singularize       write_inheritable_attribute :route_name, options[:singleton] ? route : route.singularize

      nested_in(*options.delete(:in)) if options[:in]

      write_inheritable_attribute(:resource_specification, Ardes::ResourcesController::Specification.new(name, options, &block))     end

    # Creates a resource specification mapping. Use this to specify how to find an enclosing resource that     # does not obey usual rails conventions. Most commonly this would be a singleton resource.

Don't worry about it. I finally figured it out. It looks like plugin methods that add funtionality to core modules (ActionController, ActiveRecord,..) will not be removed from the memory table though we say config.reload_plugins as the rails is not reloadable even in development mode.

-Satynos