RailsCasts Pro episodes are now free!

Learn more or hide this

robsilva's Profile

GitHub User: robsilva

Comments by

Avatar

Rails looks at the collection object, figures out what kind of object is is, and automagically looks for a partial by that name.

For example, if the controller set us an instance var like so:
@completed_tasks = Task.where(complete: true)

Rails goes like:
So you want me to render this bad boy? What kind of instance var is that? It then figures that it is a "Task" collection, then it assumes that you must have a partial named "_task" that will display it.

Silly Rails...