设计确认不能在最新版本中工作 [英] devise confirmable not working in newest version
问题描述
我最近从Devise 1.2升级到了1.4.9,除了我的可确认的模块,一切似乎都有效。电子邮件的工作以及整个过程。但确认页面始终为空。它工作,它确认电子邮件帐户,但它不会重定向用户并抛出406错误。
I recently upgraded from Devise 1.2 to 1.4.9 and everything seems to work except my confirmable module. Email works as well as the entire process. But the confirmation page is always blank. It works and it confirms the email account, but it does not redirect the user and throws a 406 error. It does the same for false confirmation attempts.
路由似乎工作正常,我在用户模型中指定了可以确认的内容,没有其他的更改。
Routes seem to work fine, I have confirmable specified in my user model, and nothing else has changed.
任何想法?我是否缺少一些设置或需要为1.4.9更新的东西?
Any ideas? Am I missing some settings or something I need to update for 1.4.9?
更新
正在生成网址的问题。由于一些未知的原因,它是用用户名前面的确认URL?这正在导致它破裂。但是我仍然不知道如何解决它。
It seems to be a problem with the URL being generated. For some unknown reason it is prepending the confirmations URL with the user name? and that is causing it to break. But i'm still not sure how to fix it.
http:// localhost:5000 / users / confirmation.someusername?confirmation_token = R7apAPhC5c3rszvhsowp
上面的URL中的用户名导致过程不起作用。
The username in the URL above causes the process not to work.
我检查了1.2(这个工作)和新版本的控制器之间的差异。
I checked the diff between the controller in 1.2 (which works) and the new version.
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message :notice, :confirmed
sign_in_and_redirect(resource_name, resource)
else
render_with_scope :new
end
end
1.4.9
1.4.9
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
sign_in(resource_name, resource)
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render_with_scope :new }
end
end
protected
# The path used after resending confirmation instructions.
def after_resending_confirmation_instructions_path_for(resource_name)
new_session_path(resource_name)
end
# The path used after confirmation.
def after_confirmation_path_for(resource_name, resource)
after_sign_in_path_for(resource)
end
错误
error
Started GET "/users/confirmation.sdfsdfsd?confirmation_token=vmxmx73xvM7sUfcvH9CX" for 127.0.0.1 at 2011-10-31 13:30:33 +0100
Processing by Devise::ConfirmationsController#show as
Parameters: {"confirmation_token"=>"vmxmx73xvM7sUfcvH9CX"}
SQL (1.1ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'vmxmx73xvM7sUfcvH9CX' LIMIT 1
SQL (0.7ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Completed 406 Not Acceptable in 28ms
推荐答案
看看你是否复制了设计意见,可能已经过时了。
Look and see if you copied the have devise views, they may be out of date.
我有类似的问题在我的网址中获得奇怪的用户ID ,设计不再使用 user_confirmation_url
有利于 confirmation_url
(从1.0开始,但仍然工作时间更长)因此您可能会删除您的自定义设计视图或更新url帮助器。
I had a similar issue getting odd user ids in my url, devise no longer uses user_confirmation_url
in favor of confirmation_url
(as of 1.0?, but it still worked a bit longer) so you might either delete your custom devise views or update the url helper.
这篇关于设计确认不能在最新版本中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!