设计首次使用rails登录

Jse*_*seb 1 ruby ruby-on-rails devise ruby-on-rails-3

如何在我的自定义会话控制器上确定该用户是第一次登录,我希望能够创建会话并重定向到welcome#index第一次将其重定向到root_url.

我拥有的代码如下

class MysessionsController < Devise::SessionsController
  def create
    self.resource = warden.authenticate!(auth_options)
    set_flash_message(:notice, :signed_in) if is_navigational_format?
    sign_in(resource_name, resource)
    respond_with resource, :location => after_sign_in_path_for(resource)    
  end
  protected
  def after_sign_up_path_for(resource)
    "http://google.com"

  end 
end
Run Code Online (Sandbox Code Playgroud)

我知道我需要自定义after_sign_up_path_for(resource)我想要的但我无法确定如何确定用户之前是否登录过设计

sam*_*207 10

你应该能够用:sign_in_count列做到这一点.如果这是0,则表示用户之前没有登录

举个例子

redirect_to ((current_user.sign_in_count == 0) ? path1 : path2 ) 
Run Code Online (Sandbox Code Playgroud)