输入框定义时:
<%= text_field_tag "search[title_cont]", "", placeholder: "", class: "form-control form-min-control jq_search" %>
1、search[搜索的字段名]
2、class属性中必须增加'jq_search'
3、按某个字段搜索表中数据时,如字段为:title,应写为title_cont或title_eq,字段名_
4、关联表的搜索,如:maintain_task 多对一个maintain_target,想找maintain_target表中的name字段时,应写为:maintain_target_name_cont,说明 [表名字]_[字段名]_[搜索符号]
5、写好之后需测试一下,会在日志中显示搜索语句,主要看一下搜索条件是否有效
时间段检索,定义时应写为:
<%= text_field_tag "search[date_range_created_at]", "", placeholder: "", class: "form-control form-min-control jq_search input-daterange-datepicker" %>
1、字段名定义需注意,[date_range_]_[字段]
2、class中一定要加入jq_search input-daterange-datepicker
eq: "等于"
eq_any: "等于任意值"
eq_all: "等于所有值"
not_eq: "不等于"
not_eq_any: "不等于任意值"
not_eq_all: "不等于所有值"
matches: "符合"
matches_any: "符合任意条件"
matches_all: "符合所有条件"
does_not_match: "不符合"
does_not_match_any: "符合任意条件"
does_not_match_all: "不符合所有条件"
lt: "小于"
lt_any: "小于任意一个值"
lt_all: "小于所有值"
lteq: "小于等于"
lteq_any: "小于等于任意一个值"
lteq_all: "小于等于所有值"
gt: "大于"
gt_any: "大于任意一个值"
gt_all: "大于所有值"
gteq: "大于等于"
gteq_any: "大于等于任意一个值"
gteq_all: "大于等于所有值"
in: "被包含"
in_any: "被任意值包含"
in_all: "被所有值包含"
not_in: "不被包含"
not_in_any: "不被任意值包含"
not_in_all: "不被所有值包含"
cont: "包含"
cont_any: "包含任意一个值"
cont_all: "包含所有值"
not_cont: "不包含"
not_cont_any: "不包含任意一个值"
not_cont_all: "不包含所有值"
start: "以改值开始"
start_any: "以任意一个值开始"
start_all: "以所有值开始"
not_start: "不以改值开始"
not_start_any: "不以任意一个值开始"
not_start_all: "不以所有值开始"
end: "以改值结尾"
end_any: "以任意一个值结尾"
end_all: "以所有值结尾"
not_end: "不以改值结尾"
not_end_any: "不以任意一个值结尾"
not_end_all: "不以所有值结尾"
'true': "等于true"
'false': "等于false"
present: "有值"
blank: "为空"
'null': "是null"
not_null: "不是null"