Forum: Ruby on Rails how to include an html file?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Filip G. (Guest)
on 2006-02-21 21:25
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/

Nick S. (Guest)
on 2006-02-21 21:35
(Received via mailing list)
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 :)

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.

This topic is locked and can not be replied to.