I’m very new to rails. I have on “main” model class “Competition” with
a supporting model class “CompDates” arranged in a 1:m relationship. In
my “list” action, I would like to order the competitions by earliest
In other languages, I probably would have simply created a view in the
database. If I’m trying to limit myself to migration supported database
usage though, that gets a little “dangerous” as the only way it appears
to make a view within the migration is using execute, which loses the
database agnostic nature to some degree.
I suspect I could easily sort them returned competitions in memory, but
that would break the pagination support that the scaffold provided and
I don’t currently see a why to make a post-retrieval sort play nice with
any pagination scheme I could think of.
I tried a rather messy :conditions clausee on the data source for the
paginaite, but as it had to use a MIN(event_date) type construct it fell
apart unless I switched to a find_by_sql style call which felt
I’m currently playing with making the aggregation :act_as_list, while
adding an ordinal to control the ordering of naturally sortable dates
feels a little odd, at least I could right the :condition without
needing to use an aggregate.
Are there other approaches I should consider?