ruby have include like php and refresh?

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.

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

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 %>

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.

You can also just use <input type="button" value="Refresh" onclick="reload();" />