I’m a bit unsure about the structure of rails…if i make my own class
for something, eg an exception class extending StandardError, where does
that class live?
thanks
max
I’m a bit unsure about the structure of rails…if i make my own class
for something, eg an exception class extending StandardError, where does
that class live?
thanks
max
On 9/18/07, Max W. [email protected] wrote:
I’m a bit unsure about the structure of rails…if i make my own class
for something, eg an exception class extending StandardError, where does
that class live?
The source file should go into the lib/ directory. That directory is
automatically added to $LOAD_PATH by the Rails initialization process.
You can “require” the file in several ways:
Use a require statement at the point of need.
Add a require statement to config/environment.rb
Take advantage of rails’ magic auto-loading gizmo that will
automatically load some_class.rb if you reference SomeClass and it’s
not already defined.
See also:
http://toolmantim.com/article/2006/12/27/environments_and_the_rails_initialisation_process
Bob S. wrote:
On 9/18/07, Max W. [email protected] wrote:
I’m a bit unsure about the structure of rails…if i make my own class
for something, eg an exception class extending StandardError, where does
that class live?The source file should go into the lib/ directory. That directory is
automatically added to $LOAD_PATH by the Rails initialization process.
You can “require” the file in several ways:
Use a require statement at the point of need.
Add a require statement to config/environment.rb
Take advantage of rails’ magic auto-loading gizmo that will
automatically load some_class.rb if you reference SomeClass and it’s
not already defined.See also:
http://toolmantim.com/article/2006/12/27/environments_and_the_rails_initialisation_process
aha - great advice, nice link as well. There’s stuff in environment
that i use but don’t really get (never a good situation).
Many thanks!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs