Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Viewing Todo Items: Part 1

Error: 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
Brandon Barrette
20,485 Points

In your routes.rb file, what is the route that you are expecting here?

Here is how it is setup in my routes.rb - sorry for the slow response.

resources :med_reminders do
    resources :reminder_detail

It 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.