Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I eventually got this working after some back and forth. The issue was that the catch all routes were a) catching more than I anticipated, and b) apparently behaving differently in development versus deployment (why this should be I'm not sure).</p> <p>Anyway, first I changed the scope to make it optional (note parentheses):</p> <pre><code>scope "(:locale)", ..... </code></pre> <p>This ensure that scoped routes are valid even if no locale is set (this is mainly to handle some issues I was experiencing with callbacks, etc).</p> <p>This allowed me to drop the two <code>root to</code> lines, keeping only </p> <pre><code>root to "home#index" </code></pre> <p>I dropped the "handles /valid-locale/fake-path" line, this was causing problems with '/' paths.</p> <p>Then kept the following catch alls after the scope (note the final one).</p> <pre><code># handles /bad-locale|anything/valid-path match '/*locale/*path', to: redirect("/#{I18n.default_locale}/%{path}") # handles /anything|valid-path-but-no-locale match '/*path', to: redirect("/#{I18n.default_locale}/%{path}"), constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" } # handles / match '', to: redirect("/#{I18n.locale}") </code></pre> <p>As a point of interest, I also had to update action_mailer to handle the new localized urls.</p> <pre><code>config.action_mailer.default_url_options = { :host =&gt; 'path.to.my.app.com', :locale =&gt; I18n.locale } </code></pre> <p>And now all appears to be working!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload