I need to write a plugin for a rails application which uses Engines. Since I have no Rails experience before, I read some documents and tutorial stuff. But Rails' class loading process lost me, feels like so much black magic behind.
The basic question I'm having is how require and require_dependency
are different? How can require_dependency
help automatically reload classes in development mode but require can't ?
I digged into rails' ActiveSupport::Dependencies and dispatcher.rb code. What I saw in the require_dependency's code is it basically adds the constants to an autoloaded_constants array. But it gets cleared in the clear_application inside dispatcher after each request.
Can someone give a clear explanation or point me to some resources which will help?
Thanks in advance!