but for the most part I only want the first definition, and its
associated children. The loading of all of the additional definitions
and their associated children is killing my site load time (but not more
than eliminating the :include all together).
Is there a way to get only the first definition under an associated
phrase ( the definitions are ordered by rank) without having to write my
own SQL ??
and their associated children is killing my site load time (but not more
than eliminating the :include all together).
Is there a way to get only the first definition under an associated
phrase ( the definitions are ordered by rank) without having to write my
own SQL ??
Rails 2.1.0 and Ruby 1.8.6
Tricky, but investigate something like:
class Phrase < ActiveRecord::Base
has_one :top_ranked_definition, :class_name => ‘Definition’,
:conditions => <<-END
definitions.rank =
(select max(rank) from definitions where phrase_id = phrases.id)
END