undefined method `oauth_token=' for User
<p>Using Devise/omniauth</p>

<p>Consider the following model</p>

<pre><code>class User &lt; ActiveRecord::Base

  has_many :usertracks, :dependent =&gt; :destroy
    mount_uploader :image, ArtistPhotoUploader

  TEMP_EMAIL_PREFIX = 'change@me'
  TEMP_EMAIL_REGEX = /\Achange@me/

  # Include default devise modules. Others available are:
  # :lockable, :timeoutable
  devise :database_authenticatable, :registerable, :confirmable,
    :recoverable, :rememberable, :trackable, :validatable, :omniauthable

  validates_format_of :email, :without =&gt; TEMP_EMAIL_REGEX, on: :update

  validates_presence_of   :image
  validates_integrity_of  :image
  validates_processing_of :image

  def self.find_for_oauth(auth, signed_in_resource = nil)

    # Get the identity and user if they exist
    identity = Identity.find_for_oauth(auth)

    user = signed_in_resource ? signed_in_resource : identity.user

    # Create the user if needed
    if user.nil?

      email_is_verified = auth.info.email &amp;&amp; (auth.extra.raw_info.verified || auth.info.verified || auth.extra.raw_info.primary_email_confirmed)
      email = auth.info.email if email_is_verified

      firstname = auth.info.name.split(' ')[0].capitalize
      surname = auth.info.name.split(' ')[1].capitalize

      if email
        user = User.where("email = ?", email).first
      else
        user = User.where("firstname = ? AND surname = ?",firstname, surname)
      end

      # Create the user if it's a new registration
      if user.blank?

        user = User.new(
          firstname: firstname,
          surname: surname,
          #username: auth.info.nickname || auth.uid,
          email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
          password: Devise.friendly_token[0,20],
          remote_image_url: auth.info.image.gsub('http://','https://')
        )
        user.oauth_token = auth.credentials.token
        user.oauth_secret = auth.credentials.secret

        user.skip_confirmation!
        user.save!
      else
        # if user found, update credentials - token/secret to overwrite previous provider
        p "this is the user #{user.inspect}"
        user.oauth_token = auth.credentials.token
        user.oauth_secret = auth.credentials.secret
        user.update!
      end
    end

    # Associate the identity with the user if needed
    if identity.user != user
      identity.user = user
      identity.save!
    end
    user
  end

  def email_verified?
    self.email &amp;&amp; self.email !~ TEMP_EMAIL_REGEX
  end

end
</code></pre>

<p>for some reason even though the user is found i get the error in the title</p>

<p>here is the exact part of the problem</p>

<pre><code>      # if user found, update credentials - token/secret to overwrite previous provider
            p "this is the user #{user.inspect}"
            user.oauth_token = auth.credentials.token
            user.oauth_secret = auth.credentials.secret
            user.update!
</code></pre>

<p>sample db entry, this is the user it prints in console just before the line with the error.</p>

<pre><code>#&lt;User id: 16, email: "change@me-16740355-soundcloud.com", encrypted_password: "$2a$10$OtCdj.7M2cWu8eOYXNc5QeWUZdrcESds
YY47WRYBfZt...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, curre
nt_sign_in_at: "2016-04-13 14:34:56", last_sign_in_at: "2016-04-13 14:34:56", current_sign_in_ip: "127.0.0.1", last_sign_i
n_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2016-04-13 14:34:55", confirmation_sent_at: nil, unconfirmed_em
ail: nil, created_at: "2016-04-13 14:34:55", updated_at: "2016-04-13 14:34:56", firstname: "Petros", surname: "Kyriakou",
image: "avatars-000015072102-sqpyn9-large.jpg", oauth_token: "1-234832-16740355-50cdc35302cdd4", oauth_secret: nil&gt;
</code></pre>