Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


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,440 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.