Skip to content

Instantly share code, notes, and snippets.

@dougal
Created June 4, 2010 11:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dougal/193903bb4e0d6e5debe1 to your computer and use it in GitHub Desktop.
Save dougal/193903bb4e0d6e5debe1 to your computer and use it in GitHub Desktop.
# sudo gem install stringex
# "Щукинская".to_ascii => Shchukinskaia
# "щукинская".to_ascii => shchukinskaia
require 'stringex'
class Post < ActiveRecord::Base
acts_as_indexed :fields => [:ascii_title, :ascii_body]
private
def ascii_title
self.title.to_ascii
end
def ascii_body
self.body.to_ascii
end
end
class PostsController < ApplicationController
def search
@posts = Post.find_with_index(params[:query].to_ascii)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment