Closed guiocavalcanti closed 12 years ago
You'll probably want to setup the api routes only in english as I don't see the point to have it several languages. Define a new Redu::Application.routes.draw do below the translated block (see the readme in backend section).
Hope it helps.
I did what you suggested with no success:
Redu::Application.routes.draw do
root :to => 'base#site_index', :as => :home
end
ActionDispatch::Routing::Translator.translate_from_file('lang/i18n-routes.yml')
Redu::Application.routes.draw do
namespace 'api' do
resources :environments, :except => [:new, :edit] do
resources :courses, :except => [:new, :edit], :shallow => true
resources :users, :only => :index
end
# ActionController::RoutingError
match '*anything', :to => 'api#routing_error'
end
end
The strange part is that when I remove the resources
part everything works. Do you have any hints about that?
Weird, as the gem shouldn't be doing anything with the second routing block.
Does it work if you remove: ActionDispatch::Routing::Translator.translate_from_file('lang/i18n-routes.yml') line?
Maybe the error is caused by the :except => []
part. I setup a fresh rails 3.0.11 project with this routes.rb file:
TranslateRoutesTest::Application.routes.draw do
resources :environment, :except => [:index, :show]
end
ActionDispatch::Routing::Translator.translate_from_file('config/locales/i18n-routes.yml')
And the same error came out. Removing the except throws no error.
By the way, it works removing the line you told me.
Maybe something was broken up when adding support to 3.1 and 3.2 I use plenty of except and only on resources on those versions and it works correctly.
If you're still using 3.0 maybe you want to give a try to https://github.com/raul/translate_routes the original gem we forked in order to have suport for 3.1 and 3.2
I got the same errors on an application using Rails 3.0, it is probably because of this Rails version.
@bobbus @guiocavalcanti did you try the orginal gem? https://github.com/raul/translate_routes it should work ok for you until you decide to switch to Rails 3.2
Yes, it worked fine for me. Thanks for the help. :)
I defined my routes as follows:
When I try to run
rake routes
I get this error:I'm trying to make a catch all route (inside api namespace) to rescue from RoutingError (see this reference for details).