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

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Adding Validations to Todo Items

Kagisho Moroka
Kagisho Moroka
8,716 Points

Problem adding todo_item

Hi All,

I'm struggling to get past the first 3min of the video :(

I keep getting this issue when executing my code in the terminal:

1) Viewing todo items displays an error with no content Failure/Error: expect(page).to have_content("There was a problem adding that todo list item.") expected to find text "There was a problem adding that todo list item." in "There was a problem adding that todo list item" # ./spec/features/todo_items/create_spec.rb:32:in block (3 levels) in <top (required)>' # ./spec/features/todo_items/create_spec.rb:31:inblock (2 levels) in <top (required)>' Finished in 0.50786 seconds 2 examples, 1 failure

Failed examples:

rspec ./spec/features/todo_items/create_spec.rb:26 # Viewing todo items displays an error with no content

Randomized with seed 48185

Also, I've created the form_for todo item as per the video, please see below:

<%= form_for [@todo_list, @todo_item] do |form| %> <% 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 |msg| %>
    <li><%= msg %></li>
  <% end %>
  </ul>
</div>

<% end %>

<%= form.label :content %> <%= form.text_field :content%>

<%= form.submit "Save" %> <% end %>

Can't seem to see where i've gone wrong. Thanks for the help in advance.

If you need anything else, please let me know.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Expected:

"There was a problem adding that todo list item."

Got:

"There was a problem adding that todo list item"

The difference is very tiny, but it changes a lot. The test expects every single character to be there.

Kagisho Moroka
Kagisho Moroka
8,716 Points

Thanks Maciej. Didn't pay attention to that small detail. You are a legend