Guest User

Untitled

a guest
Feb 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. returning(
  2. :select => "DISTINCT operator_shortcode_price_points.*, MAX(operator_shortcode_price_points.valid_from) AS valid_from",
  3. :order => "valid_from DESC",
  4. :group => "operator_shortcode_id, price_point_id"
  5. ) do |selekt|
  6.  
  7. # Returns full list of current prices for operator/shortcode combination
  8. named_scope :current, { :conditions => "valid_from <= NOW()" }.merge(selekt)
  9.  
  10. # Returns full list of prices on passed date for operator/shortcode combination
  11. #
  12. # OperatorShortcodePricePoint.on('2008-03-03') => array
  13. #
  14. named_scope :on, lambda { |date| { :conditions => ["valid_from <= ?", Date.parse(date)] }.merge(selekt) }
  15. end
Add Comment
Please, Sign In to add comment