Useful ActiveSupport::Dependencies
It is quite handy to use rails’ auto-loading functionality on a non-rails ruby project. For e.g. if you want the classes in your lib folder to be auto-loaded, the following piece of code will help:
require 'active_support'
Dependencies.load_paths << "#{File.join(File.dirname(__FILE__), 'lib')}"
Say you have a file lib/answer.rb which defines class Answer; end;. This will be required when you first use Answer constant in your code.
About this entry
You’re currently reading “Useful ActiveSupport::Dependencies,” an entry on blog.7thcross.com
- Published:
- 04.06.08 / 5pm
- Category:
- rubyonrails, tools
No comments
Jump to comment form | comments rss [?] | trackback uri [?]