使用 Rails 3.2.9 和设计 2.1.2。当用户访问http://localhost:3000/users/sign_up
(与生产环境相同,localhost:3000
用 URL 替换)时,他们会注册。提交时,它们会被/users/sign_up
反复重定向到。铬报告:
This webpage has a redirect loop
The webpage at http://localhost:3000/users/sign_up has resulted in too many redirects.
日志显示用户已创建,并且用户表也已更新以进行登录(实际上,如果我们随后转到另一个 URL,则用户已创建并在网站上登录):
←[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) 设计/注册#edit PUT /users(.:format) 设计/注册#update DELETE /users(.:format) 设计/注册#destroy