mbigras
mbigras

Reputation: 8055

How do you configure ActionCable to work with Heroku?

I'd like to configure ActionCable to work on Heroku.

I've tried changing my cable.yml file into cable.yml.erb so I can evaluate ENV['REDISTOGO_URL'] like so:

cable.yml.erb:

development:
  adapter: async

test:
  adapter: async

production:
  adapter: redis
  url: <%= ENV["REDISTOGO_URL"] %>

But now I'm getting the following error:

2016-11-23T02:24:20.551375+00:00 app[web.1]: E, [2016-11-23T02:24:20.551320 #4] ERROR -- : There was an exception - NoMethodError(undefined method `fetch' for nil:NilClass)
2016-11-23T02:24:20.551478+00:00 app[web.1]: E, [2016-11-23T02:24:20.551408 #4] ERROR -- : /app/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.0.1/lib/action_cable/server/configuration.rb:24:in `pubsub_adapter'
2016-11-23T02:24:20.551480+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.0.1/lib/action_cable/server/base.rb:72:in `block in pubsub'
2016-11-23T02:24:20.551481+00:00 app[web.1]: /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
2016-11-23T02:24:20.551482+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.0.1/lib/action_cable/server/base.rb:72:in `pubsub'

If I hard code the url it will work:

cable.yml:

development:
  adapter: async

test:
  adapter: async

production:
  adapter: redis
  url: redis://redistogo:[email protected]:10903/

But I think I shouldn't commit the actual url.

Is there anyway around this?

Note: I found this chunk of code and it seems like it might help but I'm not sure.

My project is at mbigras/depot

Upvotes: 0

Views: 811

Answers (1)

Jyotsna
Jyotsna

Reputation: 34

Try renaming cable.yml.erb to cable.yml itself. On my local machine it worked for me:

development:
  adapter: redis
  url: <%= ENV["REDIS_URL"] %>

Upvotes: 1

Related Questions