mercredi 25 mars 2020

Switch locales in i18n and Mounted Engine

I'm having trouble with the scope "(:locale)" and mount SimpleDiscussion::Engine => "/forum" is giving me this error: ActionController::UrlGenerationError in SimpleDiscussion::ForumThreads#index

And this route not matches: No route matches {:action=>"index", :controller=>"simple_discussion/forum_threads", :locale=>:es}

This is part of my routes

Rails.application.routes.draw do

  scope "(:locale)", locale: /en|es/ do

    mount SimpleDiscussion::Engine => "/forum"

   ...

end

This is the view that gave me the error

<% if I18n.locale == :es %>
  <%= link_to t('home.navbar.english'), url_for( locale: :en ), class: "nav-link dropdown-toggle", method: :get %>
<% elsif I18n.locale == :en %>
   <%= link_to t('home.navbar.spanish'), url_for( locale: :es ), class: "nav-link dropdown-toggle", method: :get %>
<% end %>

Is there a way to config locales and mounted engines? Thanks!

Aucun commentaire:

Enregistrer un commentaire