登录用户主页错误

时间:2015-12-14 20:21:00

标签: ruby-on-rails authentication devise

我在我的PagesController中添加了一个skip_before_action :authenticate_user!来覆盖我的ApplicationController中的before_action :authenticate_user!,以便未签名的用户访问网站。现在,当登录用户点击主页按钮时,他们将被发送到未登录用户主页

class ApplicationController<的ActionController ::基

 # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_action :authenticate_user!

  def after_sign_in_path_for(resource)
    if current_user.plan.name == "mentor"
      mentor_root_path
    elsif current_user.plan.name == "mentee"
      mentee_root_path
    end
  end
  def after_sign_out_path_for(resource)
    root_path
  end
end

class PagesController< ApplicationController中

skip_before_action :authenticate_user!

  def home
    @mentor_plan = Plan.find(1)
    @mentee_plan = Plan.find(2)
  end

  def about
  end
end

0 个答案:

没有答案