ruby-on-rails – 设计确认无法在最新版本中运行

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 设计确认无法在最新版本中运行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我最近从Devise 1.2升级到1.4.9,除了我的确认模块外,一切似乎都有效.电子邮件以及整个过程都有效.但确认页面始终为空白.它工作并确认电子邮件帐户,但它不会重定向用户并引发406错误.对于错误确认尝试,它也是如此.

路由似乎工作正常,我已在我的用户模型中指定确认,并且没有其他任何更改.

有任何想法吗?我是否遗漏了一些设置或需要更新1.4.9的内容

UPDATE

这似乎是生成URL的问题.由于某些未知原因,它是在前面加上确认URL和用户名吗?这导致它破裂.但我仍然不确定如何解决它.

http://localhost:5000/users/confirmation.someusername?confirmation_token=R7apAPhC5c3rszvhsowp

上面的URL中的用户名导致进程无法正常工作.

我检查了1.2(有效)控制器和新版本之间的差异.

1.2

  1. # GET /resource/confirmation?confirmation_token=abcdef
  2. def show
  3. self.resource = resource_class.confirm_by_token(params[:confirmation_token])
  4.  
  5. if resource.errors.empty?
  6. set_flash_message :notice,:confirmed
  7. sign_in_and_redirect(resource_name,resource)
  8. else
  9. render_with_scope :new
  10. end
  11. end

1.4.9

  1. # GET /resource/confirmation?confirmation_token=abcdef
  2. def show
  3. self.resource = resource_class.confirm_by_token(params[:confirmation_token])
  4.  
  5. if resource.errors.empty?
  6. set_flash_message(:notice,:confirmed) if is_navigational_format?
  7. sign_in(resource_name,resource)
  8. respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name,resource) }
  9. else
  10. respond_with_navigational(resource.errors,:status => :unprocessable_entity){ render_with_scope :new }
  11. end
  12. end
  13.  
  14. protected
  15.  
  16. # The path used after resending confirmation instructions.
  17. def after_resending_confirmation_instructions_path_for(resource_name)
  18. new_session_path(resource_name)
  19. end
  20.  
  21. # The path used after confirmation.
  22. def after_confirmation_path_for(resource_name,resource)
  23. after_sign_in_path_for(resource)
  24. end

错误

  1. Started GET "/users/confirmation.sdfsdfsd?confirmation_token=vmxmx73xvM7sUfcvH9CX" for 127.0.0.1 at 2011-10-31 13:30:33 +0100
  2. Processing by Devise::ConfirmationsController#show as
  3. Parameters: {"confirmation_token"=>"vmxmx73xvM7sUfcvH9CX"}
  4. sql (1.1ms) SELECT a.attname,format_type(a.atttypid,a.atttypmod),d.adsrc,a.attnotnull
  5. FROM pg_attribute a LEFT JOIN pg_attrdef d
  6. ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  7. WHERE a.attrelid = '"users"'::regclass
  8. AND a.attnum > 0 AND NOT a.attisdropped
  9. ORDER BY a.attnum
  10.  
  11. User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'vmxmx73xvM7sUfcvH9CX' LIMIT 1
  12. sql (0.7ms) SELECT a.attname,a.attnotnull
  13. FROM pg_attribute a LEFT JOIN pg_attrdef d
  14. ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  15. WHERE a.attrelid = '"users"'::regclass
  16. AND a.attnum > 0 AND NOT a.attisdropped
  17. ORDER BY a.attnum
  18.  
  19. Completed 406 Not Acceptable in 28ms

解决方法

查看并查看是否复制了设计视图,它们可能已过期.

我有一个类似issue越来越多的用户ID在我的网址,设计不再使用user_confirmation_url赞成confirmation_url的(如1.0?,但它仍然工作的时间长一点),所以你可以将其删除您的自定义设计视图或更新网址助手.

猜你在找的Ruby相关文章