04.01.08

Posted in Rails at 12:35 pm by jasonb

If you were following the excellent has_many :through blog, you may find you can’t use with_scope in the methods defined on your association. Instead, just send :with_scope along.

has_many :active_campaigns, :through => :campaign_distributions do
  def <<(active_campaign)
    CampaignDistribution.send(:with_scope, :create => {}) {
      self.concat active_campaign
    }
  end
end

Leave a Comment

What's a blog without spam: the large, fair, mighty, and great Wordpress Hashcash?