# Default Page

**URL:** <https://www.ruby-forum.com/t/default-page/173785>\
**Category:** Rails\
**Created:** [August 14, 2009, 7:15pm UTC](https://www.ruby-forum.com/t/default-page/173785 "2009-08-14T19:15:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmckinstry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pmckinstry](https://www.ruby-forum.com/u/pmckinstry)\
**Post date:** [August 14, 2009, 7:15pm UTC](https://www.ruby-forum.com/t/default-page/173785/1 "2009-08-14T19:15:08Z")

</div>

Hi there,

I want to have a default index page which just uses the layout (from  
layout/application.html.erb) - however the default index page in public  
does not seem to use the layouts, it doesnt need to call any controller  
at this point just display the default layout, how can I achieve this?

Thanks

---

<div class="post-metadata">

**Author:** ![pmckinstry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pmckinstry](https://www.ruby-forum.com/u/pmckinstry)\
**Post date:** [August 14, 2009, 7:27pm UTC](https://www.ruby-forum.com/t/default-page/173785/2 "2009-08-14T19:27:40Z")

</div>

Hi Pete,

On Fri, 2009-08-14 at 19:15 +0200, Pete M. wrote:

> Hi there,
> 
> I want to have a default index page which just uses the layout (from  
> layout/application.html.erb) - however the default index page in public  
> does not seem to use the layouts, it doesnt need to call any controller  
> at this point just display the default layout, how can I achieve this?

You have to get rid of public/index.html. All pages delivered by Rails  
result from calls to controller methods. If all you want is to render  
the default layout, then just define an empty view that gets rendered  
via an empty controller method and either call the method explicitly or  
make it your default with map.root.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![pmckinstry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pmckinstry](https://www.ruby-forum.com/u/pmckinstry)\
**Post date:** [August 14, 2009, 7:34pm UTC](https://www.ruby-forum.com/t/default-page/173785/3 "2009-08-14T19:34:57Z")

</div>

bill walton wrote:

> Hi Pete,
> 
> On Fri, 2009-08-14 at 19:15 +0200, Pete M. wrote:
> 
> > Hi there,
> > 
> > I want to have a default index page which just uses the layout (from  
> > layout/application.html.erb) - however the default index page in public  
> > does not seem to use the layouts, it doesnt need to call any controller  
> > at this point just display the default layout, how can I achieve this?
> 
> You have to get rid of public/index.html. All pages delivered by Rails  
> result from calls to controller methods. If all you want is to render  
> the default layout, then just define an empty view that gets rendered  
> via an empty controller method and either call the method explicitly or  
> make it your default with map.root.
> 
> HTH,  
> Bill  
> Thanks Bill,

So I should just set a empty view in one of my controllers, or should I  
create a dummy controller just for this index page?

Pete

---

<div class="post-metadata">

**Author:** ![pmckinstry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pmckinstry](https://www.ruby-forum.com/u/pmckinstry)\
**Post date:** [August 14, 2009, 8:11pm UTC](https://www.ruby-forum.com/t/default-page/173785/4 "2009-08-14T20:11:34Z")

</div>

On Fri, 2009-08-14 at 19:34 +0200, Pete M. wrote:

> Thanks Bill,

You’re welcome.

> So I should just set a empty view in one of my controllers, or should I  
> create a dummy controller just for this index page?

After thinking about your earlier post a bit more though I’d say you may  
want to think this thing through a bit more.

A layout contains the base html for the site’s pages including the

 section and components of the section that are common to all the pages that will use that layout. Headers, footers, navigation, etc. Each 'page' delivers its content into the \<%= yield %\> in the layout.

If all the rest of the site’s pages will display everything that’s on  
the index page, then either of the approaches you mention would work and  
it’s just a judgment call. That would be a pretty unusual index page,  
though. At least in my experience.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![pmckinstry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pmckinstry](https://www.ruby-forum.com/u/pmckinstry)\
**Post date:** [August 14, 2009, 8:52pm UTC](https://www.ruby-forum.com/t/default-page/173785/5 "2009-08-14T20:52:25Z")

</div>

Well in this case its the start of a admin section of a site, where  
firstly it just displays the left nav and the main content is blank.  
Perhaps in the future the main content won’t be blank but for now thats  
how it is.

Its also makes me think about how controllers should work in this case,  
as this is effectively a home page and doesn’t use any of the other  
controllers until a option has been selected from the nav - so using a  
blank def from one of the other controllers seems a bit odd.

I was thinking perhaps there should be a ‘home’ controller and home  
model, which at the moment the home model did nothing, but perhaps did  
something later…

Thanks again for your help!

Pete
