How to set locale default_url_options for functional tests (Rails)

后端 未结 10 1737
予麋鹿
予麋鹿 2020-12-30 07:00

In my application_controller, I have the following set to include the locale with all paths generated by url_for:

  def default_url_options(options={})
    {         


        
10条回答
  •  执笔经年
    2020-12-30 07:19

    I tried a lot of examples, but only this one helped me. It is concise and simple. Add this code snippet to the test.rb:

    Rails.application.configure do
      # ... other config ...
    
      routes.default_url_options[:locale] = :en
    end
    

    Works on Rails 5.1.4

提交回复
热议问题