I created a new file in app/views/students called courses.html.erb
Then I try to reference it at app/views/students/show.html.erb:
<%= link_to ‘courses’, courses_student_path(@student) %>
However I am getting
undefined method `courses_student_path’ for #<#:0x1052d1648>
What step did I miss?
Note that you never link to views. It is always some action in some controller which in turn renders that view. In this case your action is
coursesinstudentscontroller and you need to create a route for it.Assuming you already had
:studentsresource defined inconfig/routes.rb:This will give you urls like
students/1/coursesand route helperscourses_student_pathandcourses_student_url.http://guides.rubyonrails.org/routing.html#adding-more-restful-actions