Difference between require and require_dependency

I was wondering what the difference was between require and require_dependency.

According to this post in comp.lang.ruby the difference is not significant but interesting. Looks like I’ll be using require_dependency from now on.

require loads a file (shared object or ruby source) once from the load path.

require_dependency isn’t a ruby core feature, it’s part of rails. It remembers the given file and loads it on each new server request (like load “path/file.rb” does), if development mode is enabled:

http://wiki.rubyonrails.com/rails/pages/RequireDependency


Florian Frank

Leave a Reply

Your email address will not be published. Required fields are marked *