ransack如何取两组参数的并集

How does ransack take the union of two sets of parameters

ransack如何取两组参数的并集

    q0 = {:field01_in=>[], :field02_in=>[], :fie4d03_in=>[value01,value02], :field02_in=
>[]}
    q1 = {:field01_in=>[], :field02_in=>[], :fie4d03_in=>[value03,value04], :field02_in=
>[value05]}

ransack 支持通过向查询哈希添加组合符 m: or (m: and) 来对查询进行分组。 (默认组合器是 and

所以如果你想 ransack 取两组参数的并集(我假设你想合并所有 q0 参数的查询 and 的 2 个结果和查询 and所有 q1 参数)

q0 = {:field01_in=>[], :field02_in=>[], :fie4d03_in=>[value01,value02], :field02_in=
>[]}
q1 = {:field01_in=>[], :field02_in=>[], :fie4d03_in=>[value03,value04], :field02_in=
>[value05]}

union_params = {groupings: [q0, q1], m: 'or'}
@q = Issue.ransack(union_params)
@issues = @q.result