user1222136
user1222136

Reputation: 553

Locale on a rails application

So I have translated all my pages using the I18n part of rails. My problem is that when I change page, the language resorts back to default. I have the following in my routes.

Games::Application.routes.draw do
  get "game_interest/new"
  get "rules/index"
  get "feedback/index"
  get "help/index"

  get "log_in"  => "sessions#new",     :as => "log_in"
  get "log_out" => "sessions#destroy", :as => "log_out"
  get "sign_up" => "users#new",        :as => "sign_up"

  get "home/index"
  get "about/index"

  resources :feedbacks
  resources :password_resets
  resources :contact_messages
  resources :wishlists
  resources :searches
  resources :help  
  resources :users
  resources :sessions

  resources :games do
    post 'email',     :on => :member
    post 'gensearch', :on => :member
    post 'consearch', :on => :member
  end

  root :to => 'home#index'
end

I tried rapping the following in a scope "(:locale)" do but I then get missing controller errors. any ideas?

Upvotes: 1

Views: 173

Answers (1)

Chris Bailey
Chris Bailey

Reputation: 4136

We use a similar pattern to the one you've tried (i.e. wrapping the routes in scope (:locale) do ... end and it works fine with us. You might need to add explicit controllers and actions to your get routes to get rid of the missing controller errors. i.e.

get "game_interest/new" => 'controller#action'
get "rules/index" => 'controller#action'
# etc, etc

I'd suggest having a play with using the scope and explicit mapping of routes to actions and testing using rake routes

Upvotes: 1

Related Questions