Re: can this be done without using find_by_sql

tonypm
Sat, 14 Feb 2009 12:32:56 -0000

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