0

devise と cancan をセットアップしましたが、登録後にユーザーを特定のページにリダイレクトするのに問題があります。

class RegistrationsController < Devise::RegistrationsController
  def after_sign_up_path_for(resource)
    "http://google.com"
  end
end

次に私のルートで:

  authenticated :user do
    root :to => "dashboard#show"
  end

ユーザーをサインアップすると、dashboard#show に送られます。google.com にアクセスできるようにしようとしていますが、できません。私は何か間違ったことをしていますか?または、CanCan を使用しているときに、サインアップ後にユーザーをリダイレクトする別の方法はありますか?

ありがとう

4

3 に答える 3

0

Devise Wiki -> How To: サインアップ (登録) に成功すると特定のページにリダイレクトする

于 2013-07-19T05:11:32.980 に答える
0

あなたはあなたに追加しますapplication_controller.rb

 def after_sign_up_path_for(resource)
   "http://google.com"
 end

ソース: redirect_to external_url

または、次のようなルートで特定の外部リンクを使用できます

# in `config/routes.rb` :

match "/google" => redirect("http://google.com"), :as => :google

# in `registrations_controller.rb` :

def after_sign_up_path_for(resource)
   google_path
end 

Devise の確認を使用している場合 (ユーザーはサインアップ後にアクティブ化されません)、after_inactive_sign_up_path_forメソッドを使用できます。

# controllers/registrations_controller.rb

class RegistrationsController < Devise::RegistrationsController


  def after_inactive_sign_up_path_for(resource)
    "http://google.com"
  end

end
于 2013-07-19T06:04:32.023 に答える