Rails devise 扩展问题

chinalegend · March 05, 2015 · Last by chinalegend replied at March 06, 2015 · 1961 hits

使用 devise 这个 gem 包,在需要登录的地方都用 before_filter :authenticate_user! 来控制,如果用户没有登录,他会执行Devise::SessionsController#new这个方法,跳转到注册页面。

我想在跳转到注册页面之前再做个判断,然后根据判断结果选择是注册还是登录。

覆盖这个方法,wiki 里面有。

也可以写一个方法,自己做判断呗,user_signed_in?可以判断用户是否登录,这样跳转也要自己来了

感谢各位的热心回答,因项目实际需求最后采用 @shallmentmo and @dingjop 的方案,这个最适合我,我也最容易理解、、、再次感谢各位 @flowerwrong and @huopo125

You need to Sign in before reply, if you don't have an account, please Sign up first.