I
I
IIITRIX2018-09-18 19:53:54
Ruby on Rails
IIITRIX, 2018-09-18 19:53:54

How to fix undefined method `remote_avatar_url='?

I'm trying to connect authorization through omniauth-twitter
Gives an error

undefined method `remote_avatar_url=' for #<User:0x0000000012a69c00> Did you mean? remove_instance_variable

def self.find_or_create_from_twitter_omniauth(auth)
  user = where(provider: auth.provider, uid: auth.uid).first_or_create
  unless auth.info.image.nil?
    user.remote_avatar_url = auth.info.image.gsub('http://', 'https://').gsub('_normal', '')
  end
  user.update(
    username: auth.info.name,
    password: Devise.friendly_token[0, 20],
    email: "#{SecureRandom.hex}#{auth.info.nickname}"
  )
  user
end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oh_shi, 2018-09-18
@oh_shi

omniauth-twitter obviously has nothing to do with it. Apparently, you copied somewhere an example from remote_avatar_url. But they did not migrate with the corresponding column in the database, which should store the string with the url.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question