Reputation: 2047
I am trying to pass both a user id, and a test id to a controller using link_to. Below is my code:
<%= link_to(test.name, user_test_result_path(:userd_id => 1, protocol.id)) %>
and below are my routes:
but I keep getting the following error:
Why is it saying that no route matches :action => show and :controller=>"test_results when according to my routes it does exist?
Upvotes: 0
Views: 388
Reputation: 20253
Dude. It says userd_id
here:
<%= link_to(test.name, user_test_result_path(:userd_id => 1, protocol.id)) %>
Spelling matters!
Also, where is that:
{9=>2...}
coming from in your params? I'm guessing you'll have more luck if you do something like:
<%= link_to(test.name, user_test_result_path(id: protocol.id, user_id: 1)) %>
Upvotes: 1
Reputation: 239551
You shouldn't be passing a hash to your path helper. If your path has two segments, :user_id
and :id
, you would simply invoke helper_name(user_id, id)
, not helper_name(user_id: user_id, id)
.
In your case you should be calling
user_test_result_path(1, protocol.id)
Upvotes: 1