I am following Ryan Bates railscasts I18n Internationalization and hitting a problem/question.
I am trying to set the language in my link, something like this:
http://localhost:3000/en/site/services for english
and
http://localhost:3000/es/site/services for spanish
I am defining this in my routes file here:
routes.rb
scope ":locale" do
get "site/home"
get "site/about_us"
get "site/faq"
get "site/discounts"
get "site/services"
get "site/contact_us"
get "site/admin"
get "site/posts"
get "categories/new_subcategory"
get "categories/edit_subcategory"
end
and I have in my application controller
before_filter :set_locale
private
def set_locale
I18n.locale = params[:locale] if params[:locale].present?
end
def default_url_options(options = {})
{locale: I18n.locale}
end
And in my views/layouts/application.html.erb
<%= link_to_unless_current "English", locale: "en" %> |
<%= link_to_unless_current "Spanish", locale: "es" %>
Now, whenever I try to run rake routes or navigate to the URL I get
C:\www\project>rake routes
rake aborted!
missing :controller
I am fairly new to routes, can someone help me see/explain the problem? Thanks in advance.