我已經在這裏得到了很大的幫助,所以謝謝你! 我想要一個搜索表單,即在我的網站上進行搜索。 現在,當我在搜索表單中添加內容時,它只會搜索列表的標題,但我希望搜索表單還搜索列表的位置和說明。 這裏是我得到在所有的位置,描述和標題搜索Ruby On Rails
lisitng.rb
def self.search(search)
if search
self.where("title like ?", "%#{search}%")
else
self.all
end
end
listings_controller.rb
def index
@listings = @ listings.search(PARAMS [:搜索])如果PARAMS [:搜索] 。當下?
我相信它是一個簡單的修復,但我無法找到我所需要的。 我感謝您的幫助!
感謝
您可以添加到您的where子句你的其他領域。查找更多有關搜索數據庫的信息。 – MrDanA 2014-09-12 18:11:14