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 Deleting Todo Lists

David Forero
David Forero
5,492 Points

What is being done with the TodoListsController?

I am not sure what is being done with the addition of the "description" on that let line of code inside the mentioned file? Why did we need to do it?

Thanks

David Forero
David Forero
5,492 Points

I Mean in the first steps of the relationships video. They modify the let! code and added a description argument.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

So in this spec, we want the test to create lists and perform various actions on them. Instead of writing all the attributes in each test, we just create a list of attributes, name them valid_attributes and pass them to every newly created object. This is what let! does for us. Initially, these attributes only contained the title, so every time a list was created, it had a title and no description. This made it impossible to pass tests when validations got introduced (checking whether description exists and has more than 3 or 4 characters). So Jason just adds this missing attribute in tests and the can pass again, with validations. I think later he will create invalid_attributes and use them to check if these validations really do what they are supposed to. These invalid attributes will purposefully contain invalid values, such as empty attributes.