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 trialgerald blady
9,052 PointsFailure/Error: click_link "Mark Complete" ActionView::MissingTemplate:
When I click mark complete in the grocery list page I get this error.
Template is missing Missing template todo_items/complete, application/complete with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/Users/jerryblady/projects/odot/app/views"
In terminal, the rspec for complete_spec is as follows..
Failures:
1) Completing todo items is successful when marking a single item complete
Failure/Error: click_link "Mark Complete"
ActionView::MissingTemplate:
Missing template todo_items/complete, application/complete with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
* "/Users/jerryblady/projects/odot/app/views"
# ./spec/features/todo_items/complete_spec.rb:11:in block (3 levels) in <top (required)>'
# ./spec/features/todo_items/complete_spec.rb:10:in
block (2 levels) in <top (required)>'
Here is the complete_spec.rb
require 'spec_helper'
describe "Completing todo items" do
let!(:todo_list) { TodoList.create(title: "Grocery list", description: "Groceries") }
let!(:todo_item) { todo_list.todo_items.create(content: "Milk") }
it "is successful when marking a single item complete" do
expect(todo_item.completed_at).to be_nil
visit_todo_list todo_list
within dom_id_for(todo_item) do
click_link "Mark Complete"
end
todo_item.reload
expect(todo_item.completed_at).to_not be_nil
end
context "with completed items" do
let!(:completed_todo_item) { todo_list.todo_items.create(content: "Eggs", completed_at: 5.minutes.ago) }
it "shows completed items as complete" do
visit_todo_list todo_list
within dom_id_for(completed_todo_item) do
expect(page).to have_content(completed_todo_item.completed_at)
end
end
it "does not give the option to mark complete" do
visit_todo_list todo_list
within dom_id_for(completed_todo_item) do
expect(page).to_not have_content("Mark Complete")
end
end
end
end
2 Answers
Maciej Czuchnowski
36,441 PointsThe test click a link. The link is made using link_to helper. Does that helper have method: :patch
in it in your code? Look at 2:29 in the video. If it does, then it means you are not redirecting wnywhere with this action in the controller.
gerald blady
9,052 Pointsah, the error was in the controller there..
gerald blady
9,052 Pointsgerald blady
9,052 PointsI see that there..
<h1><%= @todo_list.title %></h1>
<table class="todo_items"> <table class="todo_items"> <thead> <tr> <th width="25%">Completed?</th> <th width="65%">Content</th> <th width="10%">Functions</th> </tr> </thead> <tbody> <% @todo_list.todo_items.each do |todo_item| %> <tr id="<%= dom_id(todo_item) %>"> <td> <% if todo_item.completed? %> <%= todo_item.completed_at %> <% else %> <%= link_to "Mark Complete", complete_todo_list_todo_item_path(todo_item), method: :patch %> <% end %> </td> <td><%= todo_item.content %></td> <td> <%= link_to "Edit", edit_todo_list_todo_item_path(todo_item) %> <%= link_to "Delete", todo_list_todo_item_path(todo_item), method: :delete, data: { confirm: "Are you sure?" } %> </td> </tr> <% end %> </tbody> </table>
<p> <%= link_to "New Todo Item", new_todo_list_todo_item_path %> </p>
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsOK, and how does your todo item controller look like?