I have just started trying to update our rails 3.2 app for internationalization. I have an optional scope in the routes, like
scope "(:locale)", locale: /en|es|zh-HK|de|fr/ do
as described by http://guides.rubyonrails.org/i18n.html.
And my url helper like
watch_url(@watch)
gets errors in the form
No route matches {:action=>"show", :controller=>"watches", :locale=>#<Watch id: 1, rule_name: "MyRule", start_time: "2014-06-08 03:30:03", end_time: nil, last_execution_time: nil, frequency_mins: 60, rest_period: 0, enabled: true, last_rule_result: false, owner: "me", one_shot: false, args: {"x"=>"", "recipients"=>"", "attributes"=>""}, state: {}, hidden: false, comment: "">}
Any ideas on why it is happening and how I can fix it?
Thanks!
EDIT:
In my application controller, I have
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
And the routes that are for the watches controller (This is an 8 year old proprietary app and we have 100+ controllers :(, so I won't include all the routes)...
$ rake routes | grep watch
watches GET (/:locale)/watches(.:format) watches#index {:locale=>/en|es|zh-HK|de|fr/}
POST (/:locale)/watches(.:format) watches#create {:locale=>/en|es|zh-HK|de|fr/}
new_watch GET (/:locale)/watches/new(.:format) watches#new {:locale=>/en|es|zh-HK|de|fr/}
edit_watch GET (/:locale)/watches/:id/edit(.:format) watches#edit {:locale=>/en|es|zh-HK|de|fr/}
watch GET (/:locale)/watches/:id(.:format) watches#show {:locale=>/en|es|zh-HK|de|fr/}
PUT (/:locale)/watches/:id(.:format) watches#update {:locale=>/en|es|zh-HK|de|fr/}
DELETE (/:locale)/watches/:id(.:format) watches#destroy {:locale=>/en|es|zh-HK|de|fr/}
I don't think the show method is relevant. The error happens in the url helper, and the flow never gets to the show code.