【发布时间】:2011-08-12 01:45:52
【问题描述】:
在用户通过设计的可确认项确认其帐户后,我正尝试将用户引导至自定义欢迎页面。自定义页面位于 /districts/setup/,可通过 districts_setup_path 访问。
为此,我添加了自定义路线,
devise_for :users, :controllers => { :registrations => 'registrations', :confirmations => 'confirmations' }并创建了我自己的控制器。然后我不得不重载confirms_controller.rb,现在有了:
(app/controllers/confirmations_controller.rb)
类 ConfirmationsController |设计::确认控制器 # GET /resource/confirmation?confirmation_token=abcdef 定义显示 self.resource = resource_class.confirm_by_token(params[:confirmation_token]) 如果resource.errors.empty? set_flash_message(:notice, :confirmed) if is_navigational_format? 登录(资源名称,资源) 重定向到区设置路径 别的 render_with_scope :新 # 不是: # respond_with_navigational(resource.errors, :status => :unprocessable_entity){ 结尾 结尾 结尾这很好用,但我很紧张,因为我没有以最理想和最稳健的方式来做这件事。特别是,我刚刚删除了我真的不明白的 respond_with_navigational( ... ) 行。
我希望将这一切都写在 Devise wiki 的操作指南中,我只是在寻找对 Rails 相当新的反馈,甚至对 Devise/engines/warden 来说更新。
【问题讨论】:
-
我一直在测试它,它似乎工作正常。
-
不应该有办法只编写一个提供正确路径的辅助方法吗?我也在努力解决这个问题。