reloadable

Stop Rails from unloading a module in development mode

限于喜欢 提交于 2020-01-22 12:46:53
问题 I have a module in my Rails app that lives in /lib module MyModule mattr_accessor :the_variable class << self def setup yield this end end end From my environments/#{RAILS_ENV}.rb file I can then set an environment-specific value for the_variable : MyModule.setup do |my_module_config| my_module_config.the_variable = 42 end This is lovely, and it seems to work (almost) fine. The problem is that in development mode, Rails via ActiveSupport::Dependencies unloads a load of modules, and reloads

ReloadableResourceBundleMessageSource vs ResourceBundleMessageSource - cache concept & other differences

只愿长相守 提交于 2020-01-04 11:03:01
问题 I am learning spring. I tried to under the use of ResourceBundleMessageSource and here is the example I tried. Main App public class MainApp { public static void main(String arg[]){ ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml"); String text = context.getMessage("s.wish", new Object[] {"saro", "stanes" }, Locale.ENGLISH); System.out.println("English... " + text); String text2 = context.getMessage("s.wish", new Object[] {"saro", "stanes" }, Locale.FRANCE); System

Stop Rails from unloading a module in development mode

妖精的绣舞 提交于 2019-12-03 08:38:49
I have a module in my Rails app that lives in /lib module MyModule mattr_accessor :the_variable class << self def setup yield this end end end From my environments/#{RAILS_ENV}.rb file I can then set an environment-specific value for the_variable : MyModule.setup do |my_module_config| my_module_config.the_variable = 42 end This is lovely, and it seems to work (almost) fine. The problem is that in development mode, Rails via ActiveSupport::Dependencies unloads a load of modules, and reloads them in time for the new request. This is usually a great behaviour because it means you don't need to