title: Rails Omniauth-github (422) The change you wanted was rejected
body: <p>I have had <a href="http://railscasts.com/episodes/241-simple-omniauth-revised?view=asciicast" rel="nofollow">this solution</a> for Omniauth &amp; Github implemented and working fine but sometime in the last few months it stopped working.</p>
  
  <p>The error I'm getting when I try to login is: (422) The change you wanted was rejected.</p>
  
  <p>Specifically in the Heroku logs I'm seeing:</p>
  
  <pre><code>ActiveRecord::RecordInvalid (Validation failed: Password can't be blank):
  app/models/user.rb:18:in `create_from_omniauth'
  app/models/user.rb:14:in `from_omniauth'
  app/controllers/sessions_controller.rb:4:in `create'
  </code></pre>
  
  <p>Do I need to save the credentials when I create the user?</p>
  
  <p>My user model:</p>
  
  <pre><code>def self.from_omniauth(auth)
    where(auth.slice("provider", "uid")).first || create_from_omniauth(auth)
  end
  
  def self.create_from_omniauth(auth)
    create! do |user|
      user.provider = auth["provider"]
      user.uid = auth["uid"]
      user.name = auth["info"]["nickname"]
      user.email = auth["info"]["email"]
      user.image = auth["info"]["image"]
   end
  end
  </code></pre>
  
  <p>Sessions controller:</p>
  
  <pre><code>class SessionsController &lt; ApplicationController
  
  def create
    user = User.from_omniauth(env["omniauth.auth"])
    session[:user_id] = user.id
    redirect_to root_url, notice: "Signed in!"
  end
  
  def destroy
    session[:user_id] = nil
    redirect_to root_url, notice: "Signed out!"
   end
  end
  </code></pre>