How to include an html file?


I have a bunch of html files with partial page content. I’d like to be
able to include the content of these files in my RoR views without
having to change or rename them.

In PHP I’d simply use

What is the RoR equivalent of this? render_file insists on it being an
rhtml template, and render_partial requires me to rename the file.

Ideally, I could put the files in a separate dir, e.g. in /public/html/



Easiest way is to simply rename them.

Other then that though you could simple open the file and spit the
results manually. So, a simple helper function:

def include_page(file_name)
result = “”, “r”) { |f| result << }

*note, not tested for typos or accuracy :slight_smile:

This should work, and you can add in a defualt directory to look in
and things to make it a little easier to work with.