简体   繁体   中英

what does this mean for linkedin gem? undefined method `downcase' for nil:NilClass

I get the following error now (didn't really change code, but started happening):

undefined method `downcase' for nil:NilClass

I have this in my controller after authenticating with OmniAuth (and getting/storing the access token/secret

  7   def show 
  8     @user = User.find(params[:id]) 
  9     @client = LinkedIn::Client.new(ENV["LINKEDIN_KEY"], ENV["LINKEDIN_SECRET"]) 
 10     @client.authorize_from_access(@user.atoken, @user.asecret) 
 11     if @user == current_user 
 12       @client.profile 
 13     else 
 14       @client.profile(:id => @user.uid) 
 15     end 
 16   end 

Driving me crazy trying to find the problem.

If you paste the complete stacktrace I can give a better solution, but basically, one of the parameters you're passing to one of the methods there, is nil.

Most probably on one of these two lines

@client = LinkedIn::Client.new(ENV["LINKEDIN_KEY"], ENV["LINKEDIN_SECRET"]) 
@client.authorize_from_access(@user.atoken, @user.asecret) 

And if it "just" started happening, without a code change, I would bet my 2 cents that one of the ENV properties is returning nil

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM