我正在尝试将搜索条件添加到Ransack gem提供的sort_link
方法中。下面是调试应用程序时得到的一个示例。
(byebug) ransack_search_object
Ransack::Search<class: Player, base: Grouping <conditions: [Condition <attributes: ["position_id"], predicate: in, values: ["", "5"]>, Condition <attributes: ["measurable_summary_height"], predicate: gteq, values: ["6060"]>], combinator: and>>
(byebug) sort_link(ransack_search_object, "Pos", %i(position_abbreviation), { controller: "players", action: "ransack_search" })
"<a class=\"sort_link \" href=\"/players/ransack_search?q%5Bs%5D=position_abbreviation+asc\">Pos</a>"
如上所示,搜索条件在ransack_search_object
中指定,但不会显示在生成的href
链接中。我不知道为什么会这样。