gist: 787 Download_button fork
public
Public Clone URL: git://gist.github.com/787.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  returning(
    :select => "DISTINCT operator_shortcode_price_points.*, MAX(operator_shortcode_price_points.valid_from) AS valid_from",
    :order => "valid_from DESC",
    :group => "operator_shortcode_id, price_point_id"
  ) do |selekt|
    
    # Returns full list of current prices for operator/shortcode combination
    named_scope :current, { :conditions => "valid_from <= NOW()" }.merge(selekt)
    
    # Returns full list of prices on passed date for operator/shortcode combination
    #
    # OperatorShortcodePricePoint.on('2008-03-03') => array
    #
    named_scope :on, lambda { |date| { :conditions => ["valid_from <= ?", Date.parse(date)] }.merge(selekt) }
  end

Owner

pusewicz

Revisions