Forum: Ruby on Rails Calling rails from a server-side include?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
52cb4115a870ff1942e7e1ae96f4306f?d=identicon&s=25 Tyler MacDonald (Guest)
on 2007-05-25 03:09
(Received via mailing list)
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:

<!--#include virtual="/main/header" -->
...

  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
52cb4115a870ff1942e7e1ae96f4306f?d=identicon&s=25 Tyler MacDonald (Guest)
on 2007-05-25 03:51
(Received via mailing list)
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:

<!--#include virtaul="/dispatch.fcgi?RAILS_ROUTE=/main/header" -->

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

  Cheers,
    Tyler



Tyler MacDonald <google.com@crackerjack.net> wrote:
>   The problem is, rails isn't recognizing that it was called as
>   Thanks,
>     Tyler
>
> >

--
This topic is locked and can not be replied to.