Rails: Overriding ActiveRecord association method

You can use block with has_many to extend your association with methods. See comment “Use a block to extend your associations” here.
Overriding existing methods also works, don’t know whether it is a good idea however.

  has_many :tags, :through => :taggings, :order => :name do
    def << (value)
      "overriden" #your code here
      super value
    end     
  end

Leave a Comment