pusher/pusher-http-ruby

TypeError: no implicit conversion of nil into String

sadfuzzy opened this issue · 11 comments

Pusher.trigger('a_channel', 'an_event', {:some => 'data'})

provides 'TypeError: no implicit conversion of nil into String' error.

@sadfuzzy have you configured the Pusher library correctly with the three credentials it needs?

Pusher.app_id = 'your-pusher-app-id'
Pusher.key = 'your-pusher-key'
Pusher.secret = 'your-pusher-secret'

If you wouldn't mind showing a bit more of your code then we can debug further.

I'm having the same issue. If I manually set app_id, key, and secret like specified above, then everything works fine, but if I only set PUSHER_URL with the correct format, then I get the TypeError.

versions:
pusher (0.15.1)
httpclient (> 2.5)
multi_json (
> 1.0)
pusher-signature (~> 0.1.8)

Did you set PUSHER_URL as an environment variable ? If yes, then you don't need to configure anything, the library will pick it up.

@jackfranklin, sure, it had no result.
It works now, I'll try to find out, how I solved it and add here.

@zimbatm Yes, I set PUSHER_URL as an environment variable, and I'm using the dotenv-rails gem, version 2.0.2.

I think my issue might be with how I'm using the rails console. Running either rails console or bundle exec rails console and then ENV['PUSHER_URL'] outputs the envvar, but Pusher.trigger(.....) still throws the TypeError.

Any insight on that?

@millenniumiguana that might be an issue with the load ordering if the dotenv-rails gem populates the ENV and the pusher gem is loaded before that. Try setting gem "pusher", require: false in your Gemfile and then require pusher in an initializer. Or make sure dotenv-rails is loaded very first, maybe by changing the position in the Gemfile.

@zimbatm thanks for your help! I was able to solve the issue by doing gem 'dotenv-rails', :require => 'dotenv/rails-now' before gem 'pusher' in my Gemfile. The key was the require of rails-now, as just fixing the order wasn't enough.

👍

having the same error, no solutions that you've posted works for me.

@philiplindblom did you check that Pusher.app_id Pusher.key and Pusher.secret where set ?

Closing as better error reporting has now been added to master