I have the acts_as_commentable and a bunch of others added to pretty much every model, is there a way to automaically add these to EVERY model ? I tried the following but it fails with an error... ActiveRecord::Base.class_eval do has_many :notes, :as => :model_with_notes, :dependent => true end fails with.... /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/ base.rb:1369:in `class_of_active_record_descendant'':NoMethodError: undefined method `abstract_class?'' for Object:Class --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Wilden
2008-Jan-08 21:03 UTC
Re: add comments to ALL models (ie automatically add has_many)
On Jan 8, 12:21 pm, uncle <akt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have the acts_as_commentable and a bunch of others added to pretty > much every model, is there a way to automaically add these to EVERY > model ?Without knowing the details, I would suggest using inheritance. Instead of trying to change ActiveRecord::Base, just derive a new class from it to hold all the common stuff, then derive your models from that class. ///ark --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---