-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locale filter generating incorrect paths when app deployed to a sub-uri #14
Comments
I have the same problem: I want to deploy my application to a subfolder, but the routes are specified to the root folder. Is there anything i can do? |
If you're having issues with locales, you should be able to use standard rails 3 routing to do the trick. You see, at the time, I wanted to generate routes like this:
This would mean that I could go to "/en/posts" or "/de/posts" depending on the language and "/posts" would dispatch to "/en/posts" by default. The problem was that, since the ":locale" part was optional, the standard rails helpers wouldn't work properly. For example, If you're not using rails 3, though, I'm afraid I can't be of any help. |
Thanks for your help. The last time I try this solution, i had the same problems with the helper methods. I solved my problem with editing the locale filter in that way:
|
Yes, that seems like it should work just fine for your particular app. Still, I'd recommend updating rails and trying out the standard routing again, just in case. You can always revert it later if it breaks :). |
I have related problem where other gems expect that Rails root_url is ending with slash. While using routing-filter root_url is not ending with slash anymore. This is caused by this block "{$2 == '/' ? '' : $2}". Quick fix would be remove the check and let the line be like this: "url.sub!(%r(^(http.?://[^/])?(.))) { "#{$1}/#{segment}#{$2}" }" but then extension filter tests would fail. |
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 asThis 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.
The text was updated successfully, but these errors were encountered: