我想让我的搜索方法为Heoku工作。我之前遇到过这个问题,并将.downcase添加到它中。 但现在,它不工作,我得到 未定义的方法`downcase”的零:NilClass未定义的方法downcase
listing.rb
def self.locsearch(search_location, search_description)
return scroped unless search_location.present? && search_description.present?
where(["LOWER(location) LIKE? AND LOWER(description) LIKE?", "%#{search_location.downcase}%", "%#{search_description.downcase}%"])
end
有谁知道问题是什么?
我改成了
def self.locsearch(location, description)
if location.present? && description.present?
where(["LOWER(location) LIKE? AND LOWER(description) LIKE?", "%#{location.downcase}%", "%#{description.downcase}%"])
else
self.all
end
end
现在它返回的所有目录,即使我的位置和说明,输入相匹配的某些上市。 为什么?
谢谢马克,这个作品。我用self.all代替了scroped(意思是有范围的,但我用它错了)。 – Rika 2014-10-09 20:12:25