-1
的值我創建了一個名爲category的屬性表。該類別有不同的價值'機場','景點'等。rails 4條件,其中來自表
我如何找到類別'景點'中的所有位置?
我想這:
@sights_markers = Location.where(:category = 'sights')
這
@sights_markers = Location.where('category = sights')
這
@sights_markers = Location.where('category = sights')
但是這給我一個錯誤。
請advise..thanks..remco
http://guides.rubyonrails.org/active_record_querying.html#conditions – 2014-09-28 09:48:00
我已閱讀主題..但我無法弄清楚如何從數據庫中找到具有特定值的記錄。 – Remco 2014-09-28 10:22:52
你應該使用內聯查詢'Location.where(「category ='sights'」)或'Location.where(category:'sights')''來轉義值。 – 2014-09-28 10:32:03