I have a non-resourceful route that uses a SHA token in the route. Here it is in my routes.rb file:
match 'permissions/confirm/:token' => 'permissions#confirm'
I can access the generated route, but I don't know what to pass in for the link_to helper.
Here is what I'm using for the link_to, which is not working:
<%= link_to "Give permission", confirm_permission_path(:token => @permission.token) %>
Thoughts?
Add :as
key to your route like match 'permissions/confirm/:token' => 'permissions#confirm', :as => :confirm_permissions
Then <%= link_to "Give permission", confirm_permissions_path(:token => @permission.token) %>
You can always use rake routes
to figure out what the name of a path is. I double-check the output of that rake task all the time to make sure I'm using the correct restful or non-restful route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With