Skip to content

Instantly share code, notes, and snippets.

@christophercotton
Created June 2, 2013 17:55
Show Gist options
  • Save christophercotton/5694291 to your computer and use it in GitHub Desktop.
Save christophercotton/5694291 to your computer and use it in GitHub Desktop.
Article sample for PG Search
class Article < ActiveRecord::Base
attr_accessible :body, :title
end
class Article < ActiveRecord::Base
attr_accessible :body, :title
include PgSearch
end
class Article < ActiveRecord::Base
attr_accessible :body, :title
include PgSearch
pg_search_scope :search_by_title, :against => :title
end
class Article < ActiveRecord::Base
attr_accessible :body, :title
include PgSearch
pg_search_scope :search_by_title, :against => :title, :using => {:tsearch => {:dictionary => "english"}}
end
class Article < ActiveRecord::Base
attr_accessible :body, :title, :pg_search_rank
include PgSearch
pg_search_scope :search_all, :against => {:title => 'A', :body => 'B'},
:using => {:tsearch => {:dictionary => "english"}}
end
class Article < ActiveRecord::Base
attr_accessible :body, :title, :pg_search_rank
include PgSearch
pg_search_scope :search_by_title, :against => :title, :using => {:tsearch => {:dictionary => "english"}}
pg_search_scope :search_by_body, :against => :body, :using => {:tsearch => {:dictionary => "english"}}
pg_search_scope :search_all, :against => {:title => 'A', :body => 'B'}, :using => {:tsearch => {:dictionary => "english"}}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment