I addressed a similar issue where I had multiple rows of items with the 
most current row for a particular item being identified as the one with 
the latest update timestamp.

I resolved by creating a simple view in the database as follows:

create view latest_items
as
select *  from items i1
where timestamp = (select max(timestamp) from items i2 where 
i1.timestamp = im2.timestamp)

Then I just created my model based on this view.

Scott Olmsted wrote:
> At 02:17 PM 10/10/2009, you wrote:
>> The other fairly standard way to deal with this sort of thing is to
>> keep the data all in one table - but add a column that indicates the
>> current row (or conversely the superceded rows). This means you don't
>> have to have a separate table - but your queries for the current value
>> should have a condition on that marker column. This is easy to do with
>> a named scope.
>
> I like that, Cynthia, it stays within Rails without adding a plugin. 
> Named scopes are, as has been said, awesome.
>
> Thanks much.
>
> Scott
>
> >


--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to