# Ruby have include like php and refresh?

**URL:** <https://www.ruby-forum.com/t/ruby-have-include-like-php-and-refresh/132370>\
**Category:** Rails\
**Created:** [March 19, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/ruby-have-include-like-php-and-refresh/132370 "2008-03-19T14:15:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 19, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/ruby-have-include-like-php-and-refresh/132370/1 "2008-03-19T14:15:27Z")

</div>

1. 

Im starting to get tired of putting all the information on my layouts  
for links to my pages. I was wondering if ruby on rails had an include  
function like php where I could put the links in one file and put one  
line on each layout.

1. 

I would also like to know how you get ruby to refresh a page using a  
button if anyone knows.

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 19, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/ruby-have-include-like-php-and-refresh/132370/2 "2008-03-19T14:20:40Z")

</div>

1. 

use partials. place your menu/links in a file named:  
\_menu.html.erb  
(the underscore at the beginning makes it a partial)

and render it in your view/layout with:  
\<%= render :partial =\> "menu %\>

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 19, 2008, 4:23pm UTC](https://www.ruby-forum.com/t/ruby-have-include-like-php-and-refresh/132370/3 "2008-03-19T16:23:42Z")

</div>

Alan Red wrote:

> Im starting to get tired of putting all the information on my layouts  
> for links to my pages. I was wondering if ruby on rails had an include  
> function like php where I could put the links in one file and put one  
> line on each layout.

Also, if your layouts are the same, or very similar, then you can just  
use a single layout (app/views/layouts/application.html.erb) and allow  
for any differences from there. If you use this approach, then you will  
have to remove the individual controller layouts as they will override  
the application default one.

> I would also like to know how you get ruby to refresh a page using a  
> button if anyone knows.

The user already has a refresh page button on their browser, however if  
you really need this, then you can add something like this, say to your  
layout:

\<%= button\_to “Refresh”, :controller =\> controller.controller\_name,  
:action =\> controller.action\_name %\>

However I haven’t checked what happens to your params through this call,  
so you may need to do something clever with them.

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 19, 2008, 4:30pm UTC](https://www.ruby-forum.com/t/ruby-have-include-like-php-and-refresh/132370/4 "2008-03-19T16:30:38Z")

</div>

Thanks guys, this really helps. Didn’t think of using a partial, will  
make things easier.

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 20, 2008, 11:56pm UTC](https://www.ruby-forum.com/t/ruby-have-include-like-php-and-refresh/132370/5 "2008-03-20T23:56:15Z")

</div>

You can also just use
