If I was to include a file (such as in a template) in php to use
across a large number of pages, I would write this:
<?php include ('navigation.html'); ?>
In turn, every time I used this code, it would “include” (or better
put, display) the content of navigation.html in the browser.
I can’t figure out how to do this is Rails. When building my layouts,
how can I include a file like this, like I would in PHP. I have files
I’d like to include remotely, but not sure how to get this done.
1. I control both servers that I'm working with, so the security risk
is practically nil.
2. The app is very small. Any performance hits I'd take by including a
remote file is acceptable.
What happened was I got the "We're sorry, but something went wrong."
page from my
app.
I would prefer it all to be on one server, but the company I'm trying
to do this for has many different projects, using different languages
on two different servers. I'd rather not include a copy on the second
server, so if I have to make a change to that one file (remember kids,
don't repeat yourself!) I have to only do it once on one server.
What happened was I got the "We're sorry, but something went wrong."
page from my
app.
I would prefer it all to be on one server, but the company I'm trying
to do this for has many different projects, using different languages
on two different servers. I'd rather not include a copy on the second
server, so if I have to make a change to that one file (remember kids,
don't repeat yourself!) I have to only do it once on one server.
=> "<HTML>\r\n<HEAD>\r\n <TITLE>Example Web Page</TITLE>\r\n</HEAD> \r
\n<body> \r\n<p>You have reached this web page by
typing"example.com",\r\n"example.net",\r\n or
"example.org" into your web browser.</p>\r\n<p>These domain
names are reserved for use in documentation and are not available \r
\n for registration. See <a href="Index of /rfc
rfc2606.txt">RFC \r\n 2606</a>, Section 3.</p>\r\n</BODY>\r\n</HTML>\r
\n\r\n"
=> "<HTML>\r\n<HEAD>\r\n <TITLE>Example Web Page</TITLE>\r\n</HEAD> \r
\n<body> \r\n<p>You have reached this web page by
typing"example.com",\r\n"example.net",\r\n or
"example.org" into your web browser.</p>\r\n<p>These domain
names are reserved for use in documentation and are not available \r
\n for registration. See <a href="Index of /rfc
rfc2606.txt">RFC \r\n 2606</a>, Section 3.</p>\r\n</BODY>\r\n</HTML>\r
\n\r\n"
Wow! This is a bad idea. Including a full page inside another page just
makes my skin crawl. If I absolutely had to do something like this I
would maybe grab the page using open(...), but then strip out only the
contents inside the body tag and render that inside the final page.
Otherwise you'll never be able to get a clean validation anything using
that "navbar page."
I don't believe the OP ever said that it would be a full page that he
would be including. He is just trying to access partials from one of
his servers on another. Presumably some of the data for the remote
one is not accessible to the local one.