# Basic Question about Base Files

**URL:** <https://www.ruby-forum.com/t/basic-question-about-base-files/117465>\
**Category:** Rails\
**Created:** [October 17, 2007, 7:38am UTC](https://www.ruby-forum.com/t/basic-question-about-base-files/117465 "2007-10-17T07:38:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [October 17, 2007, 7:38am UTC](https://www.ruby-forum.com/t/basic-question-about-base-files/117465/1 "2007-10-17T07:38:16Z")

</div>

Ooooh, I’m having so much fun with Ruby on Rails.

I have the students assigning to parents, the parents are able to come  
login… it’s great.

That’s the functional part. As I get more of it working I am sure I’ll  
have questions about that.

Until then:

What do I do for the “static” files on the site. For every site you  
build don’t you have an “About” a “Contact” and “Help” page? Things  
right off the root? Right now I have them in the Application directory  
and a route points ‘/:action’ to :controller =\> Application (or  
something like that, I’m home now instead of in my office).

I want them to all have the layout from the rest of the site,  
obviously.

Is there a usual method for this?

Thanks,  
–Colin

---

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [October 17, 2007, 7:47am UTC](https://www.ruby-forum.com/t/basic-question-about-base-files/117465/2 "2007-10-17T07:47:02Z")

</div>

> I have the students assigning to parents, the parents are able to come  
> login… it’s great.

Rails rules like no web platform has ruled before. Welcome to the inner  
circle who no longer need to be told that!

Now how are your unit tests?

> What do I do for the “static” files on the site. For every site you  
> build don’t you have an “About” a “Contact” and “Help” page? Things  
> right off the root? Right now I have them in the Application directory  
> and a route points ‘/:action’ to :controller =\> Application (or  
> something like that, I’m home now instead of in my office).

I never heard of the Application object used directly as a controller.

Put them in the most convenient app/view/controller/ folder, and name  
them  
all .rhtml. Don’t bother to write their actions, and access them by  
default  
route - /controller/help, /controller/contact, etc.

Or put them, as raw html, in /public/, and link to them from /. But this  
requires the .html extension, which is tacky.

–  
Phlip

---

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [October 17, 2007, 7:53am UTC](https://www.ruby-forum.com/t/basic-question-about-base-files/117465/3 "2007-10-17T07:53:27Z")

</div>

On Oct 16, 2007, at 10:37 PM, Colin S. wrote:

> What do I do for the “static” files on the site. For every site you  
> build don’t you have an “About” a “Contact” and “Help” page? Things  
> right off the root? Right now I have them in the Application directory  
> and a route points ‘/:action’ to :controller =\> Application (or  
> something like that, I’m home now instead of in my office).
> 
> I want them to all have the layout from the rest of the site,  
> obviously.
> 
> Is there a usual method for this?

My understanding is you still need to (or normally would) use  
controller/action.

So if you put those at /company/about, /company/contact you would  
still create a Company controller, it just wouldn’t do very much.

As for giving all pages the same look, I’ve been exploring how to do  
this in Rails, and just finished writing an article about it (still  
some unanswered questions, but I’ll get to those).

[http://gregwillits.wordpress.com/2007/10/16/modular-page-layouts-in-](http://gregwillits.wordpress.com/2007/10/16/modular-page-layouts-in-)  
ruby-on-rails/

– gw

---

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [October 17, 2007, 4:44pm UTC](https://www.ruby-forum.com/t/basic-question-about-base-files/117465/4 "2007-10-17T16:44:42Z")

</div>

On 10/17/07, Colin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What do I do for the “static” files on the site. For every site you  
> build don’t you have an “About” a “Contact” and “Help” page? Things  
> right off the root? Right now I have them in the Application directory  
> and a route points ‘/:action’ to :controller =\> Application (or  
> something like that, I’m home now instead of in my office).

I think it’s a good idea to use a single controller for all these, but  
don’t use ‘application’, since that’s a base class for your other  
controllers. Call it ‘static’ or something.

You can use caching on these pages if they are truly static.

Also, use named routes instead of a catch-all route.

map.about ‘/about’, :controller =\> ‘static’, :action =\> ‘about’  
map.help ‘/help’, :controller =\> ‘static’, :action =\> ‘help’

Then in your view you can write:

\<%= link\_to ‘About Us’, about\_url %\>

Makes it _real_ easy to reorganize your URL’s without having to track  
down all your link\_to’s

> I want them to all have the layout from the rest of the site,  
> obviously.

If your layout is in layouts/application.rhtml, you don’t have to do  
anything. Otherwise, you need to specify the layout in your  
StaticController.
