How can I modify a where/like condition on a search query in Rails:
find(:all, :conditions => [\"lower(name) LIKE ?\", \"%#{search.downcase}%\"])
For those like me who are having trouble on add the unaccent
extension for PostgreSQL and get it working with the Rails application, here is the migration you need to create:
class AddUnaccentExtension < ActiveRecord::Migration
def up
execute "create extension unaccent"
end
def down
execute "drop extension unaccent"
end
end
And, of course, after rake db:migrate
you will be able to use the unaccent
function in your queries: unaccent(column) similar to ...
or unaccent(lower(column)) ...