Reset guide initializers

In application.rb I have

config.autoload_paths += %W(#{config.root}/lib 

Therefore, when I change the class under lib, my code reloads.

However, when I tried to add config / initializers to autoload, I noticed that my code was not updating.

If I write an extension for a string class, I have to restart the rails every time I change my code.

Please inform?

+5
source share
2 answers

Initializers load only when the rails start (and never reboot). When you redo config/initializers, you will restart the rails every time.

Of course, you can make sure that your code is defined in /lib, so you can still make sure that it works using your test suite.

. lib/speaker.rb

module Speaker
  def speak
    puts "Ahum, listen: #{self.to_s}"
  end
end

-

class String
  include Speaker
end

, .

, .

+5

, rails. . . .

'lib'

lib. lib

Rails-: config.reload_classes_only_on_change . true. config.cache_classes , .

+3

All Articles