> But how to return records with no Orders.... ? I'm thinking that I may
> need something along the lines of:
> But that seems ugly.
>
> Any suggestions for neater ways?
>
How about using counter caches - something like:
class Order < ActiveRecord::Base
belongs_to :customer, :counter_cache => true
end
class Customer < Person
has_many :orders
default_scope :conditions => { :orders_count > 0}
end
http://guides.rails.info/association_basics.html#belongs-to-association-reference
(section 4.1.2.4)
Cheers,
Andy
--
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.