diff --git a/app/models/crop.rb b/app/models/crop.rb index b5340c71b..ba2b8acaa 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -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 diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 1cc46fe93..c89328904 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -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