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 Cleaning Up Our Code

Chad Flores
Chad Flores
7,913 Points

"errors prohibited" message when adding new todo item

I am getting the following error when the new or edit todo item page loads: "0 errors prohibited this todo item from being saved:"

+downloaded the program files and my model validations looks correct +form partial matches Jason's file +controller matches

What am I missing that would cause the error to render before any action is taken?

Hey Chad Flores :

Could you explain this a bit more? I'm getting the same errors, and so I feel like it must be something that was missed somewhere. Were you getting this? And if so, how did you fix it?

zero-errors

Maybe I just need to wait for a later video?

4 Answers

Hi Jim Withington ,

Not sure if this question is stale at this point, but I ran into the same issue, and I think it's an issue with the video.

Basically, when you copy/paste the code from the new and edit.html.erb files into the partial, you need to bring the if-statement with it and surround the "Error Explanation" div. So the partial would have this code in front of the div:

<% if @todo_item.errors.any? %>

and the end tag after the div:

<% end %>

For some reason, Jason doesn't add this in the example, and I'm not really sure why (different version of Rails? In any case, I'm not sure how the div would NOT show on the page in Jason's version, so if the video is right, I'd love someone to explain why it works).

Gabriele Rossi
Gabriele Rossi
5,887 Points

Awesome, thank you spalak :)

Sage Elliott
Sage Elliott
30,003 Points

Thank you for adding your solution! Helped me out!

Binary Soul
Binary Soul
4,592 Points

if you use PUMA or WEBRICK as server, just take a look in the console what he is doing while you fetch that error message. Maybe the problem is not in the View or the Controller, i think you will find it in the "Validations" inside your model.

Just take a look in the console, and spot for SQL querys that have been executed

Chad Flores
Chad Flores
7,913 Points

Turns out the <% if @todo_item.errors.any? %> and <% end %> wrapper in my form was missing.

Chad Flores
Chad Flores
7,913 Points

Thank you for the feedback B Soul.