我正在使用 squeel,我的 Event.rb 模型中有一个搜索方法,它从 text_field 输入接收参数(字符串)
def self.search(search)
if search
self.where{date.month.strftime("%B").matches("%#{search}%")}
else
find(:all)
end
end
我想要完成的是,如果用户在 Event.date.month 中输入“fe”或“ap”搜索以进行匹配(“february”、“april”等)。目前只输入月份编号 02、04 等。
我会很感激任何帮助