Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View Acts_as_indexed and UTF-8.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# 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
Something went wrong with that request. Please try again.