Page layouts / general site layout with RoR



I’m pretty new to the whole RoR thing (coming from a .NET background)
and have gone through some tutorials both in books and online.

In the tutorials the controllers / views make sense. But suppose I have
a layout, images, CSS, etc my designer has given me. The index or home
page has some general info, and might have some dynamic info coming
from the database.

The question I have is - do I create a controller just for this page?
It’s not a page that is simply listing records, or a data entry screen
for a table (as you see in tutorials). It’s a page with dynamic data
coming from possibly multiple pages.

So what’s the recommendation here?

Thanks in advance!


If you do want dynamic data on the page, then yup, you need to create
a controller. Many of us create a content_controller.rb for static
pages. You can then specify routes that pretty up the URLs to the
actions for this controller – e.g., map.connect ‘’, :controller =>
‘content’, :action => ‘index’ would make the / path load the index
action of the controller (assuming public/index.html has been removed).

If the page is completely static, you can place the content in public/
index.html instead. The downside to this approach is that you have
to duplicate the application layout in the file itself – it won’t be
able to use any layouts in app/views/layouts.

Building an e-commerce site with Rails?


Thanks for pointing me in the right direction Benjamin.

For anyone else that might have this newbie question, I googled
‘routes’ and happened across this page that explains it a little