Ruby on rails 设计可确认的路由
我已经实现了Desive Confirmatible,它工作正常。当用户首次注册时,他们会获得:Ruby on rails 设计可确认的路由,ruby-on-rails,devise,Ruby On Rails,Devise,我已经实现了Desive Confirmatible,它工作正常。当用户首次注册时,他们会获得: 重新定向到本地主机上的应用程序根目录:3000/en “带有确认链接的邮件已发送到您的电子邮件地址。请打开链接激活您的帐户。” 到目前为止还不错 然后,我更新了应用程序控制器: class ApplicationController < ActionController::Base before_filter :authenticate_user! end class Appli
- 重新定向到本地主机上的应用程序根目录:3000/en
- “带有确认链接的邮件已发送到您的电子邮件地址。请打开链接激活您的帐户。”
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
end
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
before_filter :set_i18n_locale_from_params
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = "Access denied!"
redirect_to root_url
end
protected
def set_i18n_locale_from_params
...
end
end
在routes.rb中,我有:
root :to => "page#index"
现在发生的是PageController#索引正在重定向用户登录。因此,问题归结为如何仅免除此项:验证用户!在应用程序控制器中
分辨率
感谢jibiel,答案是:
class PageController < ApplicationController
skip_before_filter :authenticate_user!
end
class PageController
傻瓜
before_filter :authenticate_user!, :unless => :devise_controller?
并自行对其控制器动作进行验证。否则,您将覆盖它们,因为它们是在您的
过滤器之前添加的
谢谢。恐怕这没用。它的行为方式完全相同。我尝试重新启动服务器,并将线路移动到应用程序控制器的最顶端。我已经在问题中添加了更多细节,以防这有所帮助。然后请提供penult action的日志。我认为这有点像开始发布“/用户”。。。由RegistrationController处理#创建为HTML。需要知道身份验证失败的确切位置。是不是只有重定向让你烦恼?案例中是否正确创建了用户?这很有帮助。我已经发布了日志,其中显示了要豁免的控制器操作:authenticate\u user!你把我带到那里了。我已经发布了解决方案。非常感谢。
before_filter :authenticate_user!, :unless => :devise_controller?