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


Shawn Wilson
Shawn Wilson
iOS Development Techdegree Student 7,049 Points

Creating a custom view to display multiple tables.

Hey guys so I'm wondering if this is possible in sure it is but I seem stuck here. So I want to build a view eg index.html.erb. In this view I want to pull data from several tables. Is this as simple as just doing the following in the controller for said view?

Def index @sites = Site.all Ect @residents = Resident.all End

Yada yada...

And then the Sam if I wanted to tie a particular table say a vehicle that belongs to a resident below the resident?

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Basically yeah, you can create any instance variables you want in the controller's action and put any stuff inside them and then iterate over them in the view wherever you want.