---
title: "Rails 6 Pass custom config to ActionCable::Server::Base"
description:
  "Rails 6 allows passing custom configuration to ActionCable::Server::Base"
canonical_url: "https://www.bigbinary.com/blog/rails-6-allows-passing-custom-configuration-to-actioncable-server-base"
markdown_url: "https://www.bigbinary.com/blog/rails-6-allows-passing-custom-configuration-to-actioncable-server-base.md"
---

# Rails 6 Pass custom config to ActionCable::Server::Base

Rails 6 allows passing custom configuration to ActionCable::Server::Base

- Author: Taha Husain
- Published: August 21, 2019
- Categories: Rails 6, Rails

Before Rails 6, Action Cable server used default configuration on boot up,
unless custom configuration is provided explicitly.

Custom configuration can be mentioned in either `config/cable.yml` or
`config/application.rb` as shown below.

```ruby
# config/cable.yml

production:
  url: redis://redis.example.com:6379
  adapter: redis
  channel_prefix: custom_

```

Or

```ruby
# config/application.rb

config.action_cable.cable = { adapter: "redis", channel_prefix: "custom_" }

```

In some cases, we need another Action Cable server running separately from
application with a different set of configuration.

Problem is that both approaches mentioned earlier set Action Cable server
configuration on application boot up. This configuration can not be changed for
the second server.

Rails 6 has added a provision to pass custom configuration. Rails 6 allows us to
pass `ActionCable::Server::Configuration` object as an option when initializing
a new Action Cable server.

```ruby

config = ActionCable::Server::Configuration.new
config.cable = { adapter: "redis", channel_prefix: "custom_" }

ActionCable::Server::Base.new(config: config)

```

For more details on Action Cable configurations, head to
[Action Cable docs](https://edgeguides.rubyonrails.org/action_cable_overview.html#configuration).

Here's the relevant [pull request](https://github.com/rails/rails/pull/34714)
for this change.

## Links

- [Human page](https://www.bigbinary.com/blog/rails-6-allows-passing-custom-configuration-to-actioncable-server-base)
