0

Ruby on Rails 3.2 のメーラー テンプレート内にこのアクションがあります。

# password_reset.text.erb

<%= edit_password_reset_path(@user.password_reset_token) %>

残念ながら、そのリンクをクリックすると、奇妙なルーティング エラーが発生します。

No route matches {:action=>"edit", :controller=>"password_resets", :locale=>"Ze92D45dUPpfwsgbFmpYeg"}

にロケールではなくlocale、ここが含まれているように見えるのは奇妙です (例:または)。password_reset_tokenende

それでedit_password_reset_path、それは自動的にローカライズされておらず、それがエラーの原因になっていると思いますか?

どうすれば修正できますか?

詳細は次のとおりです。

class PasswordResetsController < ApplicationController  
  def edit
    @user = User.find_by_password_reset_token!(params[:id])
  end
end

# routes.rb
scope '(:locale)' do
  resources :password_resets
  ....
end
4

1 に答える 1

1

トークンをクエリ パラメータとして送信する必要があります。

edit_password_reset_path(@user, password_reset_token: @user.password_reset_token)
# Passing in the @user fulfills the :id section of the url.

そうedit_password_reset_path(@user.password_reset_token)することで、セクションにリセットトークンを提供しています:locale

ロケールも提供するには:

edit_password_reset_path(@user, locale: "de", password_reset_token: @user.password_reset_token)
于 2013-02-11T20:31:06.417 に答える