2010-07-05 126 views
2

在我的rails應用程序中,我擁有需要幷包含在控制器中的模塊。 問題是:我必須重新啓動應用程序,每次我在這些模塊進行任何更改。 任何解決方案?在不重新啓動rails的情況下更改ruby模塊應用程序


包括模塊

#rails_application/lib/services/test.rb 

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

控制器

#rails_application/app/controllers 
class TestController < ApplicationController 

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

    def index 
    render :text => start 
    end 

end 
+1

請編輯您的問題,包括顯示您如何在控制器中包含模塊的代碼。 – 2010-07-05 20:52:51

回答

2

在發展,它應該重新加載每次訪問。 在生產模式下,你可以通過修改

config/environments/production.rb 

更改以下行假關閉緩存。

config.cache_classes = false 

然後重新啓動應用程序。

它重新加載更改而不重新啓動服務器。


更新 你可以嘗試load而不是require

load 'services/test.rb' 
+0

不,這發生在開發模式 – 2010-07-06 11:59:01

+0

我更新了答案。隨着'負載',它每次都會重新加載。 – OmniBus 2010-07-07 10:33:13

+0

它工作!謝謝 – 2010-07-09 00:16:07

相關問題