named scope is definitely the way to go. check out http://guides.rubyonrails.org/active_record_querying.html#_named_scopes for more options (especialy named scope with argument)
On 14 Ún, 13:32, tonypm <tonypmar...@hotmail.com> wrote: > Just to finish the story. > > Sorry - the distinct in the select is needed, I missed it out. > > Going a step further, I now have: > > named_scope :flagged_repairs, :select => 'distinct repairs.*', :joins > => :repair_notes, :conditions => ["notes.flagged = ?", true] > > So in my search, where I am building a dynamic scope (thanks to > railscasts) > I can do: > > scope.flagged_repairs.paginate(:page=>page, :per_page=>per_page) > > And it all appears to work!! > > Incredibly neat > > Tonypm --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---