title: Rails 3.1 Devise Oauth for Facebook routing confusion
body: <p>After following:</p>
  
  <p><a href="https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview">https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview</a></p>
  
  <p>I can sign up a user via Facebook. But I'm struggling to define my own redirects.</p>
  
  <p>Obviously it's perfect that an existing user that already facebook signed up/in redirects to my app and continues on, but it's the case of the users who are newly created via facebook i'm interested in.</p>
  
  <pre><code>class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
    def facebook
      # You need to implement the method below in your model
      @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
  
      if @user.persisted?
        flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind =&gt; "Facebook"
        sign_in_and_redirect @user, :event =&gt; :authentication
      else
        session["devise.facebook_data"] = request.env["omniauth.auth"]
        redirect_to new_user_registration_url
      end
    end
  end
  </code></pre>
  
  <p>What does user.persisted mean? find_for_facebook_oauth does the same as the devise wiki page stipulates; i.e. finds the user by email and returns it if they exists, or creates a new user with a autogen password if not. </p>
  
  <p>But I need it to redirect newly created users to a page where they set their password. I don't want the stub password to persist, I want users to immediately be presented with a screen to a) confirm their name and b) confirm their password.</p>
  
  <p>I have such a screen implemented for people who accept invites (via <a href="https://github.com/scambra/devise_invitable/">https://github.com/scambra/devise_invitable/</a> ) that is in views/devise/invitations/edit  - which would be perfectly suitable for this if it will work.</p>
  
  <p>Where should I add the redirection to and what format would this sort of redirection take? I find the facebook method above quite confusing to interpret. I can't understand why it would ever redirect to a new user registration url - the user is created or exists, so what does the persists relate to?</p>
  
  <p>Obviously confused, so help appreciated. :)</p>
  
  <p>Thanks,</p>
  
  <p>Dave</p>