Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,
我有一个模型作为区域,其中我的列是“位置”,其中包含一个特定区域的单词
现在我想将此位置与可能包含多个单词的参数进行比较。
例如
位置列的值为“喀拉拉邦”,我的参数值为“印度喀拉拉邦马拉普拉姆”
那么现在我如何在 Rails 中触发查询?
试试这个:
params = "Malappuram, Kerala, India" Area.where(:location => params.split(',')) # params.split(',') = ["Malappuram", "Kerala", "India"]
你可以使用include?
include?
params[:location].include? location
文档