1

ユーザーのサインイン/サインアップにdeviseを使用しています。ログイン前のページからユーザーをリダイレクトしたい。しかし、deviseは適切にリダイレクトされていません。サインインすると、ユーザーにサインインしますが、/ user/sign_inページでエラーがスローされます。

「Firefoxは、サーバーがこのアドレスの要求を決して完了しない方法でリダイレクトしていることを検出しました。」

戻って、ユーザーがログインしていることを示すページをリロードすると。

私のアプリケーションコントローラーは次のようになります。

class ApplicationController < ActionController::Base
 protect_from_forgery
  def after_sign_in_path_for(resource)
   stored_location_for(resource) || request.referer || root_path
  end
  def after_sign_out_path_for(resource_or_scope)
   request.referrer
  end
end

製品購入ページでブートストラップモーダルスクリプトを使用しました。これは、ページのモーダルスクリプトで使用されるログインボタンに対して完全に機能します。ただし、ヘッダーのログインボタン、つまりアプリのすべてのページに不適切なリダイレクトエラーが発生します。

その理由は何でしょうか?

4

1 に答える 1

1

For your method that will store the user's location before being redirected to a sign in page you will want something like this.

  before_filter :store_location

  def store_location
    session[:user_return_to] = request.fullpath
  end

  def after_sign_in_path_for(resource)
   session[:user_return_to] || request.referrer || root_path
  end

This will store the location when a user enters your website in a session variable and then redirect the user to that session variable once they have logged in.

于 2013-03-04T15:37:28.407 に答える