0

いくつかの深刻な問題があります。うまく機能する複数の言語選択を作成しましたが、リンクは常に変化しています。http://localhost:3000/en/productsそのようなリンクをクリックしたときから

<%= link_to image_tag('en.png',:alt => 'description', :title =>  (I18n.t 'english') ), params.merge(:locale => :en) %>

しばらくしてこのようなものにするには、アプリ内を移動して別のリンクをクリックしています

http://localhost:3000/manufacturer_products?locale=en&manufacturer=Christophel

問題は routes.rb ファイル内にあると思います。

これは私のルートファイルです

 root :to => 'home#index'
    devise_for :admin_users, ActiveAdmin::Devise.config
  ActiveAdmin.routes(self)
  get "about_us/index"

namespace :products do
  resources :categories do
    resources :products
  end

  resources :products, only: :index
end

namespace :products do
  resources :manufacturs do
    resources :products
  end

  resources :products, only: :index
end
  get "about/index"
  match ":locale/products/search" => "products#search"
  match "/contacts", to: "contacts#index"
  match "/products", to: "products#index"
  match "/home", to: "home#index"
  match "/about_us", to: "about_us#index"
  match "/news", to: "news#index"
  match "/manufacturer_products", to: "manufacturer_products#index"

match '/:locale' => 'home#index'
scope "(:locale)", :locale => /en|lv|ru/ do
 resources :products, :manufacturers, :categories, :news, :ActiveAdmin, :manufacturer_products

end

どうにかして namespace:products ルートを locale ルートとマージする必要があることは理解していますが、そもそも何をすればよいかわかりません。

ありがとう

4

2 に答える 2

0

私は解決策を見つけました。ルートファイルでは、ルートの正しい順序がありませんでした。ファイルの最後にあるロケールでルーティングを処理するこのルート。だからうまくいかなかった。

scope "(:locale)", :locale => /en|lv|ru/ do
   resources :products, :manufacturers, :categories, :news, :ActiveAdmin, :manufacturer_products, :about_us, :contacts
end

このコードをファイルの先頭に移動したところ、完全に機能するようになりました。:)

于 2013-08-28T10:03:09.470 に答える