quite new to Ruby and Rails, so it's probably a dumb question ;)
I try to get a "i18n" route working with an "admin" namespace.
So, my routes file looks like
scope '/:locale' do
root 'admin#index', as: :root
namespace :admin do
resources :foos
end
end
In my ApplicationController, I have
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
{ locale: I18n.locale }
end
If I "rake routes", I got the following
root GET / admin#index
GET /:locale(.:format) admin#index
admin_foos GET /:locale/admin/foos(.:format) admin/foos#index
And I can reach /en/admin/foos
The problem I'm facing, is that if I print a path within a view, (even the path from my form, ...) I will get the path /admin/foo?locale=en. And this url with end with a 404.
The calls to the path are simple such
<%= link_to 'Back', admin_foos_path %>
I guess I'm missing something, but have no idea of what. Any help will be appreciated !
Regards, Benjamin