How to create headers or footers “system wide” for all pages in RoR

To create a header/footer “system wide” for all pages:

go to app\views\layouts
delete everything (unless you want a certain controller’s worth of pages to NOT have the header/footer), then create a file called “application.rhtml”
One way to do so is rename one of the old one’s (that you delete) as application.rthml. That will now serve as the “layout” for all views, into which file you can create your default header/footer.

If you want a generic header for each file (since we just deleted all the headers) put

 <title><%= controller.class %> <%= controller.action_name %></title>

in the layout and rename it application.rhtml and delete all the others and you have a perfect header/footer system.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.