Hello, there.
I'm currently trying to use the locale filter in an application of mine. I'm using rails 3.0.0 and routing-filter 0.2.0. I'm deploying using Phusion Passenger.
The application is deployed to a sub-uri, for example:
The problem is that every url that is generated from the standard rails helpers does not take into account that sub-uri and instead of /foo/en/articles/
, generates paths like /en/foo/articles/
, which promptly break, since my apache/nginx can find nothing there.
There is no problem with recognition, if I enter the url http://example.com/foo/en/articles
, the routing filter recognizes it.
From what I understood while poking around, recognition is probably not a problem, since it has the full request and can find the real root of the application. However, generation works on pure option hashes and I can either tweak those, or manupulate the resulting string. In the localization filter in particular, generating seems to call prepend_segment
which is defined as
url.sub!(%r(^(http.?://[^/]*)?(.*))) { "#{$1}/#{segment}#{$2 == '/' ? '' : $2}" }
This works just fine in general, but doesn't do the right thing for a sub-uri deployment.
Unfortunately, I'm not very knowledgeable about the rails internals, so I have no idea what I could work with in that filter. If I had access to the current request, I could probably extract the prefix from that and shave it off from the string, but I'm not sure if that's even possible.
Regards, Andrew.