0

Devise を使用していますが、認証されたユーザーがそのユーザーのプロフィール ページにアクセスする必要があります。

URL パスは次のようになります... www.website.com/profile/1

現在、認証されたユーザーはここに着陸します

www.website.com/

問題のあるコードの routes.rb ファイルからのスニペットを次に示します。

  authenticated :user do
    root :to => 'home#index' # TODO direct to profile page
  end

上記を変更して、ユーザーが ...www.website.com/profile/1 にリダイレクトされるようにするにはどうすればよいですか

注: これは、プロファイルの rake ルートの出力です。

                   profiles GET        /profiles(.:format)                           profiles#index
                            POST       /profiles(.:format)                           profiles#create
                new_profile GET        /profiles/new(.:format)                       profiles#new
               edit_profile GET        /profiles/:id/edit(.:format)                  profiles#edit
                    profile GET        /profiles/:id(.:format)                       profiles#show
                            PUT        /profiles/:id(.:format)                       profiles#update
                            DELETE     /profiles/:id(.:format)                       profiles#destroy
4

1 に答える 1

0

Devise メソッドを上書きできますafter_sign_in_path_for:

def after_sign_in_path_for(resource)
  profile_path(resource.profile)
end
于 2013-02-12T22:45:39.567 に答える