Rails loads controllers, helpers and models on each request.
My controllers have a bunch of modules which include methods for shared actions
Each time I change the modules, I have to restart Rails for the changes in the actions to take effect
Any idea how I can tell rails to reload these modules too?
Update:
My directory structure is like so:
app/
controllers/
app1/
users_controller.rb
app2/
users_controller.rb
lib/
templates/
controllers/
users_controller_template.rb
Both App1::UsersController and App2::UsersController load UsersControllerTeplate like so:
# app/controllers/app1/users_controller.rb
class App1::UsersController < App1::ApplicationController
require "templates/controllers/users_controller_template"
include Templates::Controllers::UsersControllerTemplate
end
# templates/controllers/users_controller_template.rb
module Templates::Controllers::UsersControllerTemplate
def self.included(base)
base.class_eval do
# some class macros called here
end
end
# actions defined here
def index
end
end
In application.rb I've added:
config.autoload_paths += %W{ #{config.root}/lib/templates/ }
But I still have to reload the server to see changes made in users_controller_template.rb
Any ideas?