Ruby on rails 在不重新启动rails应用程序的情况下更改ruby模块

Ruby on rails 在不重新启动rails应用程序的情况下更改ruby模块,ruby-on-rails,Ruby On Rails,在我的rails应用程序中,我有控制器中所需和包含的模块。 问题是:每次对这些模块进行任何更改时,我都必须重新启动应用程序。 有什么解决办法吗 范例 包含模块 #rails_application/lib/services/test.rb module Services module TestService def start 'Service started successfully' end end end 控制器 #rails_applicatio

在我的rails应用程序中,我有控制器中所需和包含的模块。 问题是:每次对这些模块进行任何更改时,我都必须重新启动应用程序。 有什么解决办法吗


范例

包含模块

#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
#rails_应用程序/应用程序/控制器
类TestControllerstart
结束
结束

在开发过程中,它应该在每次访问时重新加载。 在生产模式下,可以通过修改

config/environments/production.rb
将以下行更改为false

config.cache_classes = false
然后重新启动应用程序

它在不重新启动服务器的情况下重新加载更改


更新 您可以尝试
load
而不是
require

load 'services/test.rb'

请编辑您的问题,以包含显示如何在控制器中包含模块的代码。不,这在开发模式下发生