需要重定向 如果用户已登录,则在主页上


Need To redirect At home page If user Already logged in

我正在使用omniauthdevise。 我的控制器是波纹管

 class OmniauthCallbacksController < Devise::OmniauthCallbacksController
      def facebook
        # You need to implement the method below in your model (e.g. app/models/user.rb)
        @user = User.from_omniauth(request.env["omniauth.auth"])

        if @user.persisted?
          sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
          set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
        else
          # session["devise.facebook_data"] = request.env["omniauth.auth"]
          redirect_to new_user_registration_url
        end
      end
    end

如果用户已登录并保留,这会将用户重定向到注册页面。我所做的更改是为了在主页上重定向用户......?????请帮帮我

在路径之后设置sign_in?

#application_controller.rb
def after_sign_in_path_for(resource_or_scope)
  case resource_or_scope
  when :user, User
    root_path
  else
    super
  end
end

使用全向身份验证设计的轨道示例

代码示例

如果您遇到其他错误,请粘贴到此处