Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (16 sloc) 463 Bytes
class MarketPrice < ActiveRecord::Base
belongs_to :game
belongs_to :fuel_market
scope :closest_to, lambda { |date|
# TODO this should have to be a GameTime
order(%{ABS(strftime('%s', "#{date.to_formatted_s(:db)}") - strftime('%s', created_at)) asc}).
order("id DESC").
limit(1)
}
validates :price, :presence => true
validates :game, :presence => true
validates :fuel_market, :presence => true
def to_s
"$#{price}"
end
end