Unexpected results when using "sort_link" helper in Ransack Gem

48 views
Skip to first unread message

David McDonald

unread,
Dec 29, 2017, 2:50:40 PM12/29/17
to Ruby on Rails: Talk

I'm trying to add my search criteria to my sort_link method that's provided by the Ransack gem. Below is a an example of what I get when debugging the application.


(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>"



As you can see above the search criteria is specified in ransack_search_object, but it doesn't appear in the href link that is generated. I'm not sure why this is the case though.  Anyone have any ideas or suggestions I could try?  Thanks!

Reply all
Reply to author
Forward
0 new messages