I was building my own class that resides in /lib folder and debugging with rails console. I quickly comes to a problem, which I have to reload! my console everytime I modified my class file. Would like to know how to auto-reload this when file changed.
Following is my configuration:
Class Location
/lib/book.rb
Code
class Book
def hello
puts 'hello'
end
end
config/application.rb
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]
Console
rails c
Book.new.hello
It doesn’t look to me like
guardwill do this, but I could be wrong. My solution, since this is coming up a lot today is to add aload_libfunction to my .irbrc file:(note that this is Rails specific, perhaps someone has a suggestion about that)
The in the Rails console I just need to run
load_liband my library code is loaded in. It’s brute force and might not be perfect but it is meeting my needs. It also doesn’t answer your question, but it’s close enough?