I want to decorate ActiveRecord with a new method so that any classes that inherit from it also have the method. I''ve been told that initializers are the way to go, yet when I put a file in initializers containing: class << ActiveRecord::Base def methodName(params) end end The method doesn''t exist. While I realize this may be the simplest of errors, I was going on some advice and I more or less would likely benefit of having a full explanation of what''s going on with initializers, "class <<" and how the best way to add methods to ActiveRecord without actually modifying the ActiveRecord class itself... -- Posted via http://www.ruby-forum.com/.
On Jun 22, 5:18 pm, Alexander Trauzzi <rails-mailing-l...@andreas- s.net> wrote:> I want to decorate ActiveRecord with a new method so that any classes > that inherit from it also have the method. > > I''ve been told that initializers are the way to go, yet when I put a > file in initializers containing: > > class << ActiveRecord::Base > > def methodName(params) > end > > end >Did you want to add a class method or were you intending to add an instance method ? Fred> The method doesn''t exist. While I realize this may be the simplest of > errors, I was going on some advice and I more or less would likely > benefit of having a full explanation of what''s going on with > initializers, "class <<" and how the best way to add methods to > ActiveRecord without actually modifying the ActiveRecord class itself... > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Jun 22, 5:18�pm, Alexander Trauzzi <rails-mailing-l...@andreas- > s.net> wrote: >> >> end >> > Did you want to add a class method or were you intending to add an > instance method ? > > FredInstance. So any instances of ActiveRecord (my models) would have the method. -- Posted via http://www.ruby-forum.com/.