Consider the following models..
class Product < ActiveRecord::Base
has_many :pricings
end
class Pricing < ActiveRecord::Base
belongs_to :server
end
Pricing is a historical tracking table for prices of products, so there may potentially be hundreds of price points captured over time. What I want to add is a way to get only the current pricing for the product.
While i can add a has_one relation to the model like the following:
has_one :current_pricing, :class_name => "Pricing", :foreign_key => "product_id",
:order => 'created_at DESC'
This will fetch me all the Pricings for the current product before returning me only the first record.
I am looking for a way to accomplish this in a more efficient manner and was hoping that someone would have input or previous experience doing something similar.