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 trial
Robert Skoubo
6,854 PointsI have a problem with two errors that I cannot find an answer for. I need help with them. Please!
Here are the two error codes that show up after running bin/rake
Failures:
1) Adding todo items is successful with valid content
Failure/Error: expect(page).to have_content("Milk")
expected to find text "Milk" in "Edit"
# ./spec/features/todo_items/create_spec.rb:20:in block (3 levels) in <top (required)>'
# ./spec/features/todo_items/create_spec.rb:19:inblock (2 levels) in <top (required)>'
2) Viewing todo items displays item content when a todo list has items
Failure/Error: expect(page).to have_content("Milk")
expected to find text "Milk" in "Edit Edit"
# ./spec/features/todo_items/index_spec.rb:35:in block (3 levels) in <top (required)>'
# ./spec/features/todo_items/index_spec.rb:34:inblock (2 levels) in <top (required)>'
I have looked at the code in the videos over and over, printed out the code in hard copy and I cannot find out what is happening.
When the app is opened in Firefox it works up to a point and then I get an error message that tells me that the item could not be saved due to 0 errors. Below is the message that is on the server:
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-12-30 13:56:28 -0800 [2014-12-30 13:56:28] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Thank you for your help!
Bob
Robert Skoubo
6,854 PointsMaciej,
I appreciate your help with this matter. I have been stuck on this one for a long time. I don't know if it is me, my computer, Firefox, or just what it is. I have been going over this for a long time and can't find the problem, that is if one really exists.
I put the latest update out on github at: https://github.com/gh4Bob652/Todo_List/commit/151da488cb238e3625d29af9e0dba7aadb51d37f
Thanks again! Happy New Year!
Bob
3 Answers
Maciej Czuchnowski
36,441 PointsOK, I caught your bugs. These are small things, easy to miss, that can give you headaches.
First thing is your todo_items index view in app/views/todo_items/index.html.erb. Your rspec error output suggested that the content of the todo item was not printed on the page although the object itself existed (there was a list item and Edit link for it). So you were missing a = symbol in line 6. It should look like that:
<%= todo_item.content %>
Second thing is the constant "0 errors" error when creating and editing items. When making a partial, you removed the if statement. Your app/views/todo_items/_form.html.erb should look like this:
<% if @todo_item.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@todo_item.errors.count, "error") %> prohibited this todo_item from being saved:</h2>
<ul>
<% @todo_item.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= form.label :content %>
<%= form.text_field :content %>
<%= form.submit "Save" %>
With these two changes your code seems to run fine and all the tests are passing. I hope this will get you back on track with Rails :)
Robert Skoubo
6,854 PointsMaciej,
Those changes made the necessary corrections to my code to make the fix. I could have looked for another month and not seen those somewhat minor changes that needed to be changed. Thank you again for your help. Have a happy and successful New Year!
Bob
Maciej Czuchnowski
36,441 PointsThanks. You too! And remember to never give up when encountering problems ;)
Robert Skoubo
6,854 PointsI won't give up. I might get a little more frustrated but giving up is not an option for me. I'm a little too stubborn and probably a little bull-headed as well. I am enjoying myself and the opportunity to learn and receive help from people like you.
Bob
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsPut your code on GitHub and link it here. Can't say I've ever seen such behavior.