You can have, on your book table, a price_id that points to it's
latest price.  Thus book.price points to its latest price, while
book.prices returns all its prices.  Do a after_create on Price to set
its book's price_id to itself so that everytime you create a price
it'll set the book's price_id.

Ramon Tayag



On Thu, Oct 2, 2008 at 7:01 AM, Anthony E.
<[EMAIL PROTECTED]> wrote:
>
> Ramon Tayag wrote:
>> Book having many :prices does make sense.  That way you get to keep
>> the history of the price of the book.  Of course, the latest price in
>> the association is the current price.
>>
>> Ramon Tayag
>
>
> The problem with that is to get the current price (most uses cases) I
> have to scan the entire 'prices' table.
>
> I'd rather do it in such a way that it only saves the current price,
> year, edition, etc. to a "stats" whenever the book is updated (without
> any explicit association).
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to