views:

55

answers:

2

How would I include a page from the public folder in one of my views? I want to include a single header like I do in PHP so when I make a change it affects all the other pages. (It is for multiple views)

+2  A: 

I'm pretty new to rails, but I guess for such task you would use Layouts: Layouts and Rendering

StefanS
Yes you're on the right track there, I think he's after a partial, in which case he'll need to move the page out of the public folder.
Ryan Bigg
A: 

For the most part, the only web pages in the public folder will be purely static (custom 404 pages, FAQ, etc). If you have a piece of static HTML that you'd like to be displayed in a lot of pages, a partial is what you're looking for.

A partial doesn't have to be tied to a controller. You can create the sub-directory:

/views/static

and fill it with a whole bunch of partials, so you would have:

/views/static/_my_first_partial.html.erb
/views/static/_my_second_partial.html.erb

and anywhere you want those fragments, you can do:

render :partial => "static/my_first_partial"

and voila, you're done!

Mike Trpcic
Thank you, you have saved me a lot of trouble.
deuces