1

申し訳ありませんが、エラーが見つかりません。ここに私の registrations_controller.rb コードがあります:

class RegistrationsController < Devise::RegistrationsController  
 protected
   def after_sign_up_path_for(resource)
 edit_user_registration_path(current_user)
 end
end

私のルートで:

  devise_for :users, :controllers => { :registrations => "registrations" }

そして、リダイレクトが機能しません...

4

2 に答える 2

1

やってみました:

class RegistrationsController < Devise::RegistrationsController
  protected

  def after_sign_up_path_for(resource)
    '/an/example/path'
  end
end

...次に、これをルートに追加します。

devise_for :users, :controllers => { :registrations => "registrations" }

これはすべて、Google を検索して約 30 分かけて見つけたものです。私のために働いた唯一のものでした。

編集: コードを突っ込んだ後、これが実際のリダイレクトになるようには見えないことも追加するかもしれません(一部のドキュメントが言っているにもかかわらず)。200円返ってきます。

于 2013-02-06T06:36:34.897 に答える
0

パスは有効である必要があります (確認してくださいrake routes | grep registration)。そうでない場合は、root_pathまたはにリダイレクトされます。"/"

  def signed_in_root_path(resource_or_scope)
    scope = Devise::Mapping.find_scope!(resource_or_scope)
    home_path = "#{scope}_root_path"
    if respond_to?(home_path, true)
      send(home_path)
    elsif respond_to?(:root_path)
      root_path
    else
      "/"
    end
  end

Deviseソースコードより

于 2013-02-06T06:48:51.300 に答える