I want to reopen the ActiveRecord::Base class in a Rails environment and is wondering about the best place to put the code. The new and altered methods should be used by all instances in the whole Rails application. Any ideas? Thanks in advance Erik Lindblad --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Your app has a lib folder for this kind of stuff. Any .rb files you put in lib will be automatically required. So if you just did lib\active_record_patches.rb module ActiveRecord class Base def self.foo "hello world" end end end That should be it. User.foo => "hello world" On Nov 12, 2007 7:06 PM, Erik Lindblad <erik-gTO0lQh45js@public.gmane.org> wrote:> > I want to reopen the ActiveRecord::Base class in a Rails environment > and is wondering about the best place to put the code. The new and > altered methods should be used by all instances in the whole Rails > application. Any ideas? > > Thanks in advance > > Erik Lindblad > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks, just what I needed. Regards Erik On 13 Nov, 05:11, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Your app has a lib folder for this kind of stuff. > > Any .rb files you put in lib will be automatically required. So if you just > did > > lib\active_record_patches.rb > > module ActiveRecord > class Base > def self.foo > "hello world" > end > end > > end > > That should be it. > > User.foo > => "hello world" > > On Nov 12, 2007 7:06 PM, Erik Lindblad <e...-gTO0lQh45js@public.gmane.org> wrote: > > > > > I want to reopen the ActiveRecord::Base class in a Rails environment > > and is wondering about the best place to put the code. The new and > > altered methods should be used by all instances in the whole Rails > > application. Any ideas? > > > Thanks in advance > > > Erik Lindblad--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Great advice, one question: Is this documented anywhere? None of my documentation seems to have it. fredistic --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Great advice, one question: Is this documented anywhere? None of my documentation seems to have it. fredistic --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---