# Calling rails from a server-side include?

**URL:** <https://www.ruby-forum.com/t/calling-rails-from-a-server-side-include/105032>\
**Category:** Rails\
**Created:** [May 25, 2007, 3:09am UTC](https://www.ruby-forum.com/t/calling-rails-from-a-server-side-include/105032 "2007-05-25T03:09:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyler\_MacDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@Tyler\_MacDonald](https://www.ruby-forum.com/u/Tyler_MacDonald)\
**Post date:** [May 25, 2007, 3:09am UTC](https://www.ruby-forum.com/t/calling-rails-from-a-server-side-include/105032/1 "2007-05-25T03:09:46Z")

</div>

Hi,

99% of my site is rails, but I have a tiny php section I just cant  
get rid of (phpbb3). I’ve turned on server-side includes on my site and  
my  
phpbb3 template starts with this:

…

The problem is, rails isn’t recognizing that it was called as  
“/main/header”; I get this error in my development.log:

ActionController::RoutingError (no route found to match  
“/forum/index.php”  
with {:method=\>:get}):

Does anybody know how to get around this? I was thinking of just  
adding a “/forum/\*” route to explicitly point to the header, but then  
there’s the problem of the footer… Any ideas would be greatly  
appreciated.  
🙂

Thanks,  
Tyler

---

<div class="post-metadata">

**Author:** ![Tyler\_MacDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@Tyler\_MacDonald](https://www.ruby-forum.com/u/Tyler_MacDonald)\
**Post date:** [May 25, 2007, 3:51am UTC](https://www.ruby-forum.com/t/calling-rails-from-a-server-side-include/105032/2 "2007-05-25T03:51:51Z")

</div>

Okay, after hacking around a bit, I figured something out, but it’s  
REALLY  
hacky. 🙂

Step #1: Include this code when rails starts up:

module ActionController  
class CgiRequest \< AbstractRequest  
alias old\_request\_uri request\_uri  
def request\_uri  
if params[‘RAILS\_ROUTE’]  
if Array === params[‘RAILS\_ROUTE’]  
return params[‘RAILS\_ROUTE’][0]  
else  
return params[‘RAILS\_ROUTE’]  
end  
else  
return old\_request\_uri  
end  
end  
end  
end

Step #2: reference rails from SSI this way:

This is fragile and hacky, but it works for what I need!

Cheers,  
Tyler

Tyler MacDonald [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The problem is, rails isn’t recognizing that it was called as  
> Thanks,  
> Tyler
> 
> >

–
