# Use the same page header/footer across apps within a domain?

**URL:** <https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998>\
**Category:** Rails\
**Created:** [January 16, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998 "2007-01-16T19:52:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [January 16, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998/1 "2007-01-16T19:52:12Z")

</div>

Let’s say I have four different rails apps which use different  
databases…  
[blog.mydomain.com](http://blog.mydomain.com)  
[store.mydomain.com](http://store.mydomain.com)  
[links.mydomain.com](http://links.mydomain.com)  
[news.mydomain.com](http://news.mydomain.com)

I’d like each app to have a consistent look and feel starting with using  
the same header, footer and stylesheets on the pages that are displayed  
in the browser. Is there someway to do that?

Can the header and footer code sit in a separate partials directory  
which they can all share?

Would using sub-directories instead of sub-domains make this easier to  
manage?

I’d like to avoid having to duplicate the header and footer assets for  
each Rails app.

I’m curious what others have come up with to solve similar issues.

Thanks,  
Dan P.

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [January 16, 2007, 8:49pm UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998/2 "2007-01-16T20:49:16Z")

</div>

Do you use a vps ?  
maybe “ln -s” will be your answer, dunno really if it will work, later i  
try it.  
If yes you can point the layout folder to the unique layout folder 😛  
hope you got it

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [January 16, 2007, 10:33pm UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998/3 "2007-01-16T22:33:18Z")

</div>

Dan P. wrote:

> Let’s say I have four different rails apps which use different  
> databases…  
> [blog.mydomain.com](http://blog.mydomain.com)  
> [store.mydomain.com](http://store.mydomain.com)  
> [links.mydomain.com](http://links.mydomain.com)  
> [news.mydomain.com](http://news.mydomain.com)
> 
> I’d like each app to have a consistent look and feel starting with using  
> the same header, footer and stylesheets on the pages that are displayed  
> in the browser. Is there someway to do that?
> 
> Can the header and footer code sit in a separate partials directory  
> which they can all share?

I could imagine you create a plugin, that contains the method and data  
that you place in these headers and footers.

Then your layouts could say  
\<%= mydomain\_header %\>

.  
.  
.

\<%= mydomain\_footer %\>

and these methods are taken from the plugin code.

The plugin code could be checked out as external projects from  
subversion repository for example, to synchronize them as you like.

Haven’t thought through how you would provide for dynamic content; I  
don’t know if the headers and footers have dynamic content (Logged in  
users?)

Your stylesheets could be accessed through  
[http://mydomain.com/styles/style.css](http://mydomain.com/styles/style.css). Don’t know if you find it  
difficult to set up a server for this or you already have one.

Stephan

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [January 16, 2007, 10:42pm UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998/4 "2007-01-16T22:42:46Z")

</div>

Stephan W. wrote:

> I could imagine you create a plugin, that contains the method and data  
> that you place in these headers and footers.

Sorry, to clarify, to be placed in the lib directory … (not  
vendor/plugins)

Stephan

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [January 16, 2007, 11:56pm UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998/5 "2007-01-16T23:56:11Z")

</div>

You might find it useful to take a look at the theme\_support plugin  
([http://www.agilewebdevelopment.com/plugins/theme\_support](http://www.agilewebdevelopment.com/plugins/theme_support)) to see an  
example of how to extend the places that Rails will search for  
layouts and views. From that starting point, it shouldn’t be hard to  
come up with a shared path you could use for your various apps.

An alternative approach if you are using subversion would be to use  
svn:externals to share paths like app/views/layouts and public/  
stylesheets. This approach would probably be more straightforward.

–  
Building an e-commerce site with Rails?  
[http://www.agilewebdevelopment.com/rails-ecommerce](http://www.agilewebdevelopment.com/rails-ecommerce)

Meet up at RailsConf:  
[http://railsconf2007.conferencemeetup.com/](http://railsconf2007.conferencemeetup.com/)

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [January 17, 2007, 12:59am UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998/6 "2007-01-17T00:59:01Z")

</div>

Dan P. wrote:

> Let’s say I have four different rails apps which use different  
> databases…  
> [blog.mydomain.com](http://blog.mydomain.com)  
> [store.mydomain.com](http://store.mydomain.com)  
> [links.mydomain.com](http://links.mydomain.com)  
> [news.mydomain.com](http://news.mydomain.com)
> 
> I’d like each app to have a consistent look and feel starting with using  
> the same header, footer and stylesheets on the pages that are displayed  
> in the browser. Is there someway to do that?
> 
> Can the header and footer code sit in a separate partials directory  
> which they can all share?

Not as far as I know, but you might be able to implement and API on one  
“master” domain that spits back HTML.

> Would using sub-directories instead of sub-domains make this easier to  
> manage?

Yes.

> I’d like to avoid having to duplicate the header and footer assets for  
> each Rails app.
> 
> I’m curious what others have come up with to solve similar issues.
> 
> Thanks,  
> Dan P.

Another way might be to use symbolic links for a shared directory (if  
all your sites are on one server), or maybe configure apache to retrieve  
content from another site using mod\_proxy?

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [January 21, 2007, 5:57am UTC](https://www.ruby-forum.com/t/use-the-same-page-header-footer-across-apps-within-a-domain/81998/7 "2007-01-21T05:57:11Z")

</div>

We’ve used symlinks to share things in the past between projects so  
that we only have one copy – models, images, etc. should work as  
well for your views.

Steven

–  
Steven S., CEO, FiveRuns  
[http://www.fiveruns.com](http://www.fiveruns.com)
