Rails 3.2.9 と Devise 2.1.2 を使用。ユーザーがアクセスするとhttp://localhost:3000/users/sign_up
(本番環境でも同じlocalhost:3000
で、URL に置き換えられます)、サインアップします。/users/sign_up
送信すると、繰り返しリダイレクトされます。Chrome レポート:
This webpage has a redirect loop
The webpage at http://localhost:3000/users/sign_up has resulted in too many redirects.
ログには、ユーザーが作成され、users テーブルもサインイン用に更新されたことが示されています (実際、別の URL に移動すると、ユーザーが作成され、Web サイトにログインしました)。
←[1m←[35mSQL (1.0ms)←[0m INSERT INTO "users" ("created_at", "current_sign_in_at", "current_sign_in_ip", "em
ail", "encrypted_password", "first_name", "last_name", "last_sign_in_at", "last_sign_in_ip", "middle_name", "p
latform_id", "remember_created_at", "reset_password_sent_at", "reset_password_token", "sign_in_count", "update
d_at", "username") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["created_at", Sat, 17 Nov 201
2 08:39:33 PST -08:00], ["current_sign_in_at", nil], ["current_sign_in_ip", nil], ["email", "test@ucode.com"],
["encrypted_password", "$2a$10$NvmaFtw/JjILrkmkDNOi7ePj29qI3LRB2zTLAxsw6GRAW7PZekGme"], ["first_name", "Test"
], ["last_name", ""], ["last_sign_in_at", nil], ["last_sign_in_ip", nil], ["middle_name", ""], ["platform_id",
1], ["remember_created_at", nil], ["reset_password_sent_at", nil], ["reset_password_token", nil], ["sign_in_c
ount", 0], ["updated_at", Sat, 17 Nov 2012 08:39:33 PST -08:00], ["username", "test"]]
←[1m←[36m (4.0ms)←[0m ←[1mcommit transaction←[0m
←[1m←[35m (0.0ms)←[0m begin transaction
←[1m←[36m (1.0ms)←[0m ←[1mUPDATE "users" SET "last_sign_in_at" = '2012-11-17 16:39:33.934552', "current_sig
n_in_at" = '2012-11-17 16:39:33.934552', "last_sign_in_ip" = '127.0.0.1', "current_sign_in_ip" = '127.0.0.1',
"sign_in_count" = 1, "updated_at" = '2012-11-17 16:39:33.953553' WHERE "users"."id" = 3←[0m
←[1m←[35m (4.0ms)←[0m commit transaction
次に、ログはリダイレクト ループを報告します。
Redirected to http://localhost:3000/users/sign_up
Completed 302 Found in 178ms (ActiveRecord: 0.0ms)
Started GET "/users/sign_up" for 127.0.0.1 at 2012-11-17 08:39:33 -0800
Processing by Devise::RegistrationsController#new as HTML
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1←[0m
Redirected to http://localhost:3000/users/sign_up
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.0ms)
Started GET "/users/sign_up" for 127.0.0.1 at 2012-11-17 08:39:34 -0800
別の新しいプロジェクトでまったく同じ動作が発生するため、驚くべきことにこれがデフォルトの動作のようです。サインアップするために /users/sign_up に誘導するべきではないですか?
rake routes
ユーザーに関連する出力:
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel user_registration POST /users(.:format) devise/registrations#create new_user_registration GET /users/sign_up(.:format) devise/registrations#new edit_user_registration GET /users /edit(.:format) device/registrations#edit PUT /users(.:format) device/registrations#update DELETE /users(.:format) device/registrations#destroy