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 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,440 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