Platinum Partner

Sharing Has_many Extensions

Sometimes you extend an ActiveRecord association this way:


has_many :things do
  def active
    find :all, :conditions => ['active = ?', true]
  end
end


You can share the same extensions using a lambda:



extensions = lambda {
  def active
    find :all, :conditions => ['active = ?', true]
  end
}

has_many :things, &extensions
has_many :more_things, &extensions


{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}