나는 PBP - 레일이있는 애자일 웹 개발과 로케일 스위처 구현에 바쁘다. 나는 영어와 스페인어 사이의 전환을 시도 할 때로케일 스위처
그러나 나는 오류가 발생합니다 :
class StoreController < ApplicationController
skip_before_filter :authorize
def index
if params[:set_locale]
redirect_to store_path(locale: params[:set_locale])
else
@products = Product.order(:title)
@cart = current_cart
end
end
end
하고있는 application.hmtl.erb의 추출물을 다음과 같이
No route matches [POST] "/en"
내 컨트롤러입니다 사용되고있다.
scope'(:locale)' do
resources :users
resources :orders
resources :line_items
resources :carts
resources :products do
get :who_bought, on: :member
end
root to: 'store#index', as: 'store'
end
내가 뭘 잘못했는지 알아낼 질수 다음과 같이
<div id="banner">
<%= form_tag store_path, class: 'locale' do %>
<%= select_tag 'set_locale', options_for_select(LANGUAGES, I18n.locale.to_s), onchange: 'this.form.submit()' %>
<%= submit_tag 'submit' %>
<%= javascript_tag "$('.locale input').hide()" %>
<% end %>
<%= image_tag("logo.png") %>
<%= @page_title || t('.title') %>
</div>
라우팅 폴더입니다./en 또는/es를 입력하면 제대로 작동합니다. 그러나 그 드롭 다운을 선택하는 것이 내가 오류 당신은 가이드와 같은 범위에 슬래시를 누락
브래킷을 사용하면 경로에 로케일을 사용하지 않고 어쨌든 시도하고 동일한 문제가 발생합니다. 그것은 제출과 관련이 있다고 생각합니다. GET으로 전화하기보다는 게시하려고하지만 그저 추측입니다. – user2021962