Skip to content

Instantly share code, notes, and snippets.

@kamal
Created January 26, 2010 10:33
Show Gist options
  • Save kamal/286731 to your computer and use it in GitHub Desktop.
Save kamal/286731 to your computer and use it in GitHub Desktop.
class Article < ActiveRecord::Base
belongs_to :author
searchable do
text :title, :boost => 2.0
text :body
text :author_name do
author.name
end
time :updated_at # for sorting by recent
string :sort_title do # for sorting by title, ignoring leading A/An/The
title.downcase.gsub(/^(an?|the)/, '')
end
boolean :published, :using => :published?
end
def published?
state == :published
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment