Max Williams
2007-Sep-18 17:39 UTC
Where would i put a home-made exception class in rails?
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bob Showalter
2007-Sep-18 18:32 UTC
Re: Where would i put a home-made exception class in rails?
On 9/18/07, Max Williams <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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: 1. Use a require statement at the point of need. 2. Add a require statement to config/environment.rb 3. 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Max Williams
2007-Sep-18 21:09 UTC
Re: Where would i put a home-made exception class in rails?
Bob Showalter wrote:> On 9/18/07, Max Williams <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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: > > 1. Use a require statement at the point of need. > > 2. Add a require statement to config/environment.rb > > 3. 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_processaha - 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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---