> Why not create your method as a module and then include it into the > classes you need it? Look at any of the plugins out there that are of > the "acts_as_xxxx" variety which add methods to the model they are > called from... just follow those examples and you shouldn't need to > directly modify AR::Base like this.
Further, adding a method to a class is a perfectly reasonable solution, and is not "monkey patching". That's when you change a preexisting method, simply because it offered no hook for you to override. In order from sublime to icky... - delegate to the behavior you need - include/extend the behavior - inherit the behavior - add the behavior to your base class - trigger the behavior with an 'if' statement - monkey-patch the behavior into a closed class Yes, folks, the lowly 'if' statement is the second-worst option in Object Oriented programming. Use it with extreme caution! --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---