views:

39

answers:

1

In my rails application, i have modules which are required and included in the controllers. The problem is: i have to restart the application every time i make any changes in these modules. Any solutions?


Example

included module

#rails_application/lib/services/test.rb

module Services
  module TestService
    def start
      'Service started successfully'
    end
  end
end

controller

#rails_application/app/controllers
class TestController < ApplicationController

  require 'services/test.rb'
  include Services::TestService

  def index
   render :text => start
  end

end
+1  A: 

In development, it should reload every you access. In production mode, you can turn off cache by modifying

config/environments/production.rb

Change the following line to false.

config.cache_classes = false

And restart the application.

It reloads the changes without restarting the server.


Update You might try load instead of require.

load 'services/test.rb'
OmniBus
No, this happens in the development mode
Ibrahim Hussein
I updated the answer. With 'load', it reloads every time.
OmniBus
It worked! Thanks
Ibrahim Hussein