-
-
Save dougal/193903bb4e0d6e5debe1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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