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 trialAndreaus Perkins
14,402 PointsCan someone explain the difference between TodoList and todo_list, when you're trying to verify the existence of titles?
Can someone explain why we're using TodoList and not todo_list (or todo_lists)?
it "displays an error when the todo list has no title" do
expect(TodoList.count).to eq(0)
Any help is appreciated.
6 Answers
Roberto Alicata
Courses Plus Student 39,959 PointsTodoList is the the name of the Model ( that inherits from ActiveRecord::Base ).
Roberto Alicata
Courses Plus Student 39,959 PointsThe Test starts expecting there are no Todo List checking TodoList.count.
Then it continue trying to add a new Todo list but without a title, so we want it returns an error and the TodoList.count still be 0. In fact, if the todolist does not have a title no records are saved in the database.
Andreaus Perkins
14,402 PointsSo why are we using "TodoList" instead of "todo_list"? I'm still confused. The app is named "odot", so I'm not sure where TodoList came from.
Andreaus Perkins
14,402 PointsSo "TodoList.count" is checking the entire class for an entry?
Roberto Alicata
Courses Plus Student 39,959 PointsYes it checks the TodoList table on the database. The TodoList is the class name for your model that was created when you wrote the command "rails generate scaffold todo_list ...." in the app/models/todo_list.rb
Andreaus Perkins
14,402 PointsThanks Roberto!
Ben Goldman
14,626 PointsThanks from me, too! Great answer.