成功注册后如何重定向到视图

时间:2016-01-11 11:38:05

标签: ruby-on-rails-4 devise

class ApplicationController < ActionController::Base
 # Prevent CSRF attacks by raising an exception.
 # For APIs, you may want to use :null_session instead.
    def after_sign_in_path_for(resource)
         redirect('../views/home/index.html.erb')
    end
    def  protect_from_forgery with: :exception
    end
end

我收到的错误消息是undefined method redirect in device。如果成功登录,我可以如何重定向到该视图。

1 个答案:

答案 0 :(得分:1)

after_sign_in_path_for期望返回一个路由,它不应该自己执行重定向(顺便说一下,方法是redirect_to,而不是redirect)。 假设您有一个HomeController,您的方法应该类似于

def after_sign_in_path_for(resource)
    home_path
end