guilhermesad / rspotify

A ruby wrapper for the Spotify Web API
MIT License
717 stars 290 forks source link

Spotify::User.new(hash) -> undefined method `merge!' for #<String:0x00007fb627e6b0d8> #185

Open eller82 opened 5 years ago

eller82 commented 5 years ago

I am trying to get a new token for my stored user:

user = Spotuser.find(6)
hash = Hash.new
hash = user.user_hash

spotify_user = RSpotify::User.new(hash)

But I am getting the following error:

completed 500 Internal Server Error in 143ms (ActiveRecord: 9.7ms)

NoMethodError (undefined method `merge!' for #):

I am storing the hash the following way into the Database

spotify_user = RSpotify::User.new(request.env['omniauth.auth'])

@user_mail = spotify_user.email 
@hash = spotify_user.to_hash

user = Spotuser.new
user.email = @user_mail
user.user_hash = @hash
user.save!
CruelMoney commented 5 years ago

Old issue, but for people who end up here:

You should probably deserialize the hash.: Check this stackoverflow question