The best way I've found to search for things where I specifically don't want character-case to matter is:
@tag = Rails.env.development? ? Category.where("LOWER(name) LIKE ?", "%#{params[:find]}%")[0] : Category.where("LOWER(name) ILIKE ?", "%#{params[:find]}%")[0]
I have to have the .env
finder because I use Heroku, and I haven't cared to get PostgreSQL setup on my dev machines. Still, isn't there something like:
@tag = Category.find_by_name(params[:find], case_sensitive: false)
Are there options that we can pass to the find_by
helper in Rails? This would be a nice one.