Reputation: 731
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)
Upvotes: 3
Views: 2575
Reputation: 25669
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!
Upvotes: 3
Reputation: 876
I'm pretty new to rails, but I guess for such task you would use Layouts: Layouts and Rendering
Upvotes: 2