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 Write Our First Tests

Nikolay Batrakov
Nikolay Batrakov
9,604 Points

Todolist object in "Build a Todo List Application"

I'm bit confused with "Todolist" object. Who created it and why is its name goes without underscore? I mean I'd be glad to know if it is a convention or I've just miss something in previous lectures

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

TodoList is written using capital letters and does not have any underscores - this means it refers to the model. So TodoList.count counts all the todo lists in the database. If something starts with lowercase letter and has underscores, it's a variable (local) or a method. If it also starts with an @ sign, it's an instance variable. This object was automatically created when Jason used scaffold - scaffold has a lot of magic in it, generates A LOT of stuff for you, and I agree, it can be confusing,because you don't see exactly what is going on under the hood. Generally this created the whole model, database migration and controller with basic methods inside, views etc. I personally don't think it's a very pedagogical approach (the scaffolds), so you'd need to read up on your own to see what this did exactly.

Nikolay Batrakov
Nikolay Batrakov
9,604 Points

Thank you Maciej, now I can feel the ground :) will look at scaffold closer.