In my config.routes.rb
file:
scope '(:locale)' do
resources :techniques, path: '/applications' do
get '/complete_list' => 'techniques#complete_list'
end
end
In my Gemfile
:
group :development, :test do
gem 'rspec-rails'
gem 'byebug'
gem 'better_errors'
gem 'factory_girl_rails'
gem 'faker'
end
group :test do
gem 'poltergeist'
gem 'capybara'
gem 'launchy'
gem 'database_cleaner'
end
In my application_controller.rb
:
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options = {})
{ locale: I18n.locale }.merge options
end
In my spec:
visit techniques_path
It always flunks with:
I18n::InvalidLocale - "applications" is not a valid locale:
And it highlights this line in my application_controller:
I18n.locale = params[:locale] || I18n.default_locale
I can make things work by changing the spec to read as:
visit techniques_path(locale: :en)
But I thought that setting up the default_url_options in the application controller would take care of that automatically. What am I missing here?