0

Hello I'm following this tutorial http://grschafer.com/guides/2013/09/07/steam-openid-and-webapi-with-rails/

I set up the login button for steam I can click my account but when I try to go back to my homepage I get hit with this error.

NoMethodError undefined method `[]' for nil:NilClass Extracted source (around line #39):

  def player
    @player ||= raw_info["response"]["players"].first
  end

  def steam_id

Thank you for your time.

Cody
  • 1

3 Answers3

0

I assume your issue lies in that raw_info is likely nil and thus throwing an error because you're trying to access the values in it that don't exist. Try getting to a debugger at this stage (you likely have one if you have a gem such as better_errors or are using Rails 4) and checking the value of raw_info.

You could also check for the existence of raw_info before your instance variable declaration.

Wakeuphate
  • 493
  • 3
  • 13
0

It's hard to say what's going on in your code without more context, but I'm 90% sure that you're receiving this error because you're trying to access the raw_info hash in the omniauth-steam module. You can't do that because isn't accessible outside of the omniauth strategy, i.e., in your controller or view. If you defined your own raw_info somewhere in your app, we won't be able to tell you what's happening unless you post that code.

Furthermore, omniauth raw_info hashes typically only contain identity credentials for one user. Looking at the source code here:

https://github.com/reu/omniauth-steam/blob/master/lib/omniauth/strategies/steam.rb

There isn't even a response key, so I'm not sure what exactly your snippet of code is meant to do.

In short, there is too little information here to say what exactly is going on with your code.

Kirk
  • 1
0

I found the fix! Turns out you needed to enter the Steam API key next to ENV Key in secrets.yml file located in the config folder.

production: secret_key_base: <%= ENV["YOUR_STEAM_KEY"] %>

Also as a side note with the new figaro version its

$ figaro install

More information about Secret_token.rb change:

secret_token.rb existed in Rails 3 and Rails 4.0 apps; it does not exist in Rails 4.1 apps. It has been replaced in Rails 4.1 by the secrets.yml file: http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#config-secrets-yml

Codin
  • 25
  • 2