make crop search case insensitive

This commit is contained in:
Skud committed 2014-07-06 20:16:59 +10:00
1 parent 8897e5149d
commit 77d2b0e950
2 files changed
+4 -1

No files matched your search

+1 -1
View File
@@ -174,7 +174,7 @@ class Crop < ActiveRecord::Base
# searches for crops whose names match the string given
# just uses SQL LIKE for now, but can be made fancier later
def self.search(query)
where("name LIKE ?", "%#{query}%")
where("name ILIKE ?", "%#{query}%")
end
end
+3
View File
@@ -321,6 +321,9 @@ describe Crop do
it "doesn't find non-matches" do
Crop.search('mush').should_not include @crop
end
it "searches case insensitively" do
Crop.search('mUsH').should include @mushroom
end
end
end