RailsCasts Pro episodes are now free!

Learn more or hide this

Matt Long's Profile

GitHub User: perlmunger

Site: http://www.cimgf.com/

Comments by Matt Long

Avatar

Fantastic! This is so helpful, Ryan. Thanks.

Avatar

I'm probably missing the obvious, but I'm curious why you would place the JSON inside a tag in the HTML. Why wouldn't a user who is interested in the JSON just append .json to the URL?

Thanks.

Avatar

Ok. I think I've finally figured it out. You have to wrap all of the query strings in plainto_tsquery, so wherever you have 'Lex Luthor', you need it to be plainto_tsquery('Lex Luthor').

So I have a scope called organization_name I use like this:

ruby
scope :organization_name, lambda { |term| { :conditions => ["to_tsvector('english', organization_name) @@ plainto_tsquery(:q)", q: term] } }

HTH

Avatar

Did you ever figure this out? I've got the same issue?

Avatar

Do you think this solution could handle a system with a single model but millions (around 4M) of records?