svenfuchs/routing-filter

No route matches "/"

Closed this issue · 3 comments

I'm trying to use the locale filter in a rails3 app. In the main everything seems to be working OK except my root deceleration is no longer recognised? I've also tried adding a simple matcher in case root_path/en is passed in but that's not matching either.

match '/:locale' => 'home#index'
root :to => "home#index"

I wondering if I'm missing here or whether anyone else is having this trouble!?

hukl commented

use the :scope feature of the rails3 router if you only need the locale functionality

I've tried that but don't know how to make it so that if a locale isn't passed in the URL the route will still work using the default locale. With the scope it simple doesn't match. Do you know if it's possible to make it optional?

This filter seems to handle it. I don't really want to define all my routes twice or force the usage of /en etc everywhere.

Any thoughts would be much appreciated!

I've just stumbled across this:

This is an optional path scope that allows to have a prepended path before a resource:
scope '(:locale)', :locale => /en|pl/ do

And it works exactly how I would like. Cannot believe I didn't spot the options path segment before!