Thinking Sphinx? Watch your scopes!

20/08/2010

I ran into this little GOTCHA, and thought it could use some more Google love, so here goes:

If you try to use named scopes with your Sphinx search, they will just be ignored. For example, I had a model JobOffer with this scope:

scope :open, { :conditions => 'job_offers.status = "open" OR job_offers.status = ""' }

And then did a search like this:

@job_offers = JobOffer.open.search query

Which, to my surprise was also showing "closed" job offers.

I found the solution over here; Sphinx has (since version 1.2) it's own form of scopes.

sphinx_scope(:open){ 
  { :conditions => {:status => ['open', '']}}
}

With that sphinx_scope in place, the above search call wìll work as expected. (well, obviously I've had to rename it to not clash with the existing Rails scope.)

ArrrrCamp presentation online

21/05/2010

Better late than never right..; I've just uploaded my presentation on Radiant for the third edition of ArrrrCamp:

What the fuzz is all about

  1. 2 pages are tagged with WYM
  2. 1 page is tagged with absolute-urls
  3. 1 page is tagged with arrrrcamp
  4. 2 pages are tagged with documentation
  5. 2 pages are tagged with editor
  6. 2 pages are tagged with extension
  7. 2 pages are tagged with extensions
  8. 1 page is tagged with minitorial
  9. 1 page is tagged with navigation
  10. 10 pages are tagged with radiant
  11. 4 pages are tagged with rails
  12. 2 pages are tagged with ruby
  13. 2 pages are tagged with shell
  14. 1 page is tagged with sifr
  15. 2 pages are tagged with troubleshooting

Github activity

  • jomz pushed to master at radiant/radiant
    • jomz committed 1bd43c1
      Merge branch 'master' of github.com:radiant/radiant
    • jomz committed 9631331
      streamlining table#pages with radiant-prototype, updating sass. See also commit 500fe2ab50bc14d85d31: proposing auto-expanding status and actions columns so these are not chopped in foreign languages
  • jomz pushed to master at jomz/radiant
  • jomz pushed to master at radiant/radiant-prototype
    • jomz committed 5ad2b9a
      refactoring sass updates from previous commit
  • jomz commented on radiant/radiant-prototype
    Comment in f1aa6c4:

    I've checked, this keeps working in IE8 (and IE7)

    there is a difference in radiant vs. radiant-prototype;
    I've had to change th.page to th.name
    I actually like the prototype-way better as it's more generic

  • jomz pushed to master at radiant/radiant-prototype
    • jomz committed f1aa6c4
      give the status and actions columns more width if they need it (think i18n)

More places where you can find me

Back to top