Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ransack with sort_link for nested resources

I have setup a nested resource like /projects/1/tasks and want to use sort_link method.

With <%= sort_link @search, :taskname %> i expect /projects/1/tasks?q... but i do get /tasks?q....

Is this possible?

like image 258
tonymarschall Avatar asked Apr 28 '26 11:04

tonymarschall


1 Answers

You can pass options to the sort_link helper, for example

sort_link @search, :taskname, { :controller => tasks, action: "index", project_id: @project.id }

where options can be anything that is accepted by the url_for helper

see: https://github.com/ernie/ransack/blob/v0.6.0/lib/ransack/helpers/form_helper.rb

like image 101
Carlos Ramirez III Avatar answered Apr 29 '26 23:04

Carlos Ramirez III



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!