I am having trouble getting a two part argument to a link_to method to work, one of which is a Ruby method, and the other a params.
When I use the following code:
<%= link_to "Sort by most active", school_course_path(current_school, :params => "by_most_active") %>
I get the error that “can’t convert String into Hash”. I have tried to follow this question in terms of syntax for params, but can’t figure out why my :params is getting the error.
Thanks.
Edit:
To provide additional context, I have the following nested routes set up:
resources :schools do
resources :courses
end
You are using
school_course_pathwhich expects a school and a course as its first 2 arguments. You need to provide it with a course after passing current_school. You shouldalso change the
paramspart with a different name likeorder. So your link_to should look something likeIf you are trying to get the most active courses for
current_school, you should useschool_courses_path