Skip to content

Instantly share code, notes, and snippets.

@DriesS
Created August 4, 2014 12:06
Show Gist options
  • Save DriesS/e95ba093d36b5f87a52f to your computer and use it in GitHub Desktop.
Save DriesS/e95ba093d36b5f87a52f to your computer and use it in GitHub Desktop.
Cache problem
class Product < StatisticsModel
has_one :active_sale, :class_name => 'Sale', :foreign_key => 'product_id', :conditions => ["sales.start_date <= ? AND (sales.end_date IS NULL OR sales.end_date > ?)", Time.zone.now, Time.zone.now], :order => "sales.start_date desc"
end
class ProductStatistic < ActiveRecord::Base
attr_protected
belongs_to :product
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment