Ryan Pool

Joined

210 Experience
2 Lessons Completed
0 Questions Solved

Activity

Posted in Datatables From Scratch Using Hotwire Discussion

Hi Chris, thanks for this episode, my index pages will never be the same.

I notice that on the first load, the sort_link_to helper doesn't know to change the name column's link to sort descending instead of ascending. That requires a user to click the name header twice if they want to sort by name descending. I'm looking for a clean way to make sure the sort_link_to helper knows the default sort column and order on the first page load.

What I have done that does work, but I'm not sure I'm comfortable with, is to have the controller method actually set params[:sort] if params doesn't have that key set already.

Do you have any thoughts on a better way?