Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMcFadden Gavender
4,893 PointsError: No route matches.... missing required keys: [:id]
Here is the error I'm receiving.
No route matches {:action=>"show", :controller=>"reminder_detail", :med_reminder_id=>#<MedReminder id: 1, medication: "My Medication Name", created_at: "2014-11-25 05:57:58", updated_at: "2014-11-25 05:57:58">, :id=>nil, :format=>nil} missing required keys: [:id]
I can fix this error by changing the code from:
<%= link_to "Add Reminders", med_reminder_reminder_detail_path(med_reminder) %>
<%= link_to "Add Reminders", med_reminder_reminder_detail_path(med_reminder, :id) %>
However, this leads to a different error as it then routes to /med_reminders/3/reminder_detail/id - the 'id' being what breaks the link.
Any ideas?
3 Answers
Brandon Barrette
20,485 PointsIn your routes.rb file, what is the route that you are expecting here?
McFadden Gavender
4,893 PointsHere is how it is setup in my routes.rb - sorry for the slow response.
resources :med_reminders do
resources :reminder_detail
end
Twiz T
12,588 PointsIt is a nested route so it looks like you need to pass in the :reminder_id
resource as well to the path helper in the view.