Re: Require a template in another one

One very important concept to grasp at the beginning is accepting the Rails conventions. No doubt the Rails Way is different than what you did before, but in my case it was often better. I didn't realize that until much later.

In this case, instead of splitting the header and footer, the rails convention is to make a layout template which the primary template is embedded in.

For example, if you create a file here: app/views/layouts/application.rhtml it will be loaded automatically as the layout file for every view. You can put a "yield" statement in this layout file which will be where the other templates are placed.

Here's what application.rhtml could look like. Simplified for example:

Of course, Rails also supports including protions of html. In this case you would create what is called a partial by putting an underscore before the view's name: app/views/my_controller/_foo.rhtml. You could then render this partial in the my_controller's views like this:

<%= render :partial => 'foo' %>

Yes, you could do this for header and footer, but I don't see a reason to since they are already in a separate layout file.