Hi guys. I am developing a web page in rails 3 with devise
authentication and internationalization with i18n gem.
I am having some problems mixing all together. The first thing I have
is my application layout where I render a header partial. In this
header I have two links to translate my page in this way (I use Haml
for the views)
= link_to image_tag('spanish.png', :height => "30px", :width =>
"30px", :class => "flag", :alt => "Español")
= link_to image_tag('english.png', :height => "30px", :width =>
"30px", :class => "flag", :alt => "English")
In my application_controller I have this
before_filter :set_locale
def set_locale
I18n.locale = request.compatible_language_from LANGUAGE_CODES
end
compatible_language_from is an action from http_accept_language gem
and LANGUAGE_CODES is a constant with the available language codes
This is working perfectly. Depending on my browser
HTTP_ACCEPT_LANGUAGE header the root page is translated in english or
spanish.
Now, I have in my routes.rb the following code
#Authentication routes definitions
devise_for :users
#Choosing custom paths for user sign_in
devise_scope :user do
get "/", :to => "devise/sessions#new"
end
root :to => "welcome#index"
Doing this "get "/" in the scope of devise I get browsing to
http://localhost:3000 with the application layout and its header and
devise stuff with no need to browse to users/sign_in etc.
I added this to the link_to tag
, :action => "update_locale"
so that when I click on "Spanish or English" the "update_locale"
action fires to update the locale but I am getting this error:
ActionController::RoutingError in Devise/sessions#new
Showing /Users/alvaro/webApps/myFirstApp/app/views/shared/
_header.html.haml where line #15 raised:
No route matches {:controller=>"devise/
sessions", :action=>"update_locale"}
Has anyone an idea on how to fix this? Maybe what is wrong is
routes.rb? My brain is getting boiled!!
Thank you very much