How to Deploy ActionCable and Rails 5 To Production

February 4, 2016

Track your progress

Sign in to track your progress and access subscription-only lessons.

Log In

Your Teacher

Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.

About This Episode

Learn how to deploy ActionCable and Rails 5 with Passenger

Notes

Resources

# If you don't have redis server already installed, 
# make sure to install that if you choose to use that as the backend
sudo apt-get install redis-server
# config/cable.yml
production:
  url: redis://localhost:6379

local: &local
  url: redis://localhost:6379

development: *local
test: *local
# config/routes.rb
mount ActionCable.server => "/cable"
# app/assets/javascripts/channels/index.coffee
App.cable = ActionCable.createConsumer("/cable")
# config/environments/production
config.action_cable.allowed_request_origins = ["https://gorails.com"]
# /etc/nginx/sites-enabled/default
server {
  listen 80;
  server_name gorails.com;

  passenger_enabled on;
  rails_env production;
  root /home/deploy/gorails/current/public;

  location /cable {
    passenger_app_group_name gorails_websocket;
    passenger_force_max_concurrent_requests_per_process 0;
  }

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root html;
  }
}

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.