Re: modifying ActiveRecord::Base - where?

Duane Johnson
Tue, 06 Dec 2005 06:21:21 -0000

On Dec 5, 2005, at 10:16 PM, Ara.T.Howard wrote:

>
> i need to add a method to ActiveRecord::Base.  to be specific
>
>   class ActiveRecord::Base
>     def self::restful *a
>       @restful = a.shift || @restful
>     end
>   end
>
> so i can
>
>   class MyModel < ActiveRecord::Base
>     has_one :foobar
>     restful true
>   end
>
> where is the currently preferred location to place a file which
> does this?
>
> -a

Traditionally, it would go in your lib/ folder and then you''d add
something like ''require "my_active_record.rb"'' in
your environment.rb
file.  I usually go one step further and add a ''patches''
folder
within ''lib'' so I can differentiate between rails additions
and other
libraries.

Nowadays, however, it seems that plugins may do exactly what you''re
after.  But it seems a little overkill to put one tiny method like
that into a plugin.

Duane Johnson
(canadaduane)