Skip to content

Commit 567417f

Browse files
authored
Change configuration for ActionCable (#360)
See article https://blog.heroku.com/real_time_rails_implementing_websockets_in_rails_5_with_action_cable Requires that PRODUCTION_HOST be set in the ENV of the production environment.
1 parent 4d0dc2d commit 567417f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Your support keeps this project going!
1010

1111
(Want to become a contributor? [Contact us](mailto:[email protected]) for an Slack team invite! Also, see ["easy" issues](https://github.com/shakacode/react_on_rails/labels/easy) and [issues for the full tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/issues?q=is%3Aissue+is%3Aopen+label%3Aeasy).)
1212

13+
# React on Rails Pro!
14+
Justin is currently working with a couple contributors on some new private examples that incorporate ShakaCode's best practices for industrial strength apps using React on Rails. If you're interested in getting access to these and/or contributing, [email [email protected]](mailto:[email protected]). Technologies will include Webpack v2, Yarn, CSS Modules, Bootstrap v4, Redux-Saga, Normalizr, Reselect, etc.
15+
1316
# ShakaCode Community
1417
Please [Subscribe](https://app.mailerlite.com/webforms/landing/l1d9x5) to keep in touch with Justin Gordon and [ShakaCode](http://www.shakacode.com/). I intend to send a monthly summary including announcements of new releases of bootstrap-loader and React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials. Subscribers will also have access to **exclusive content**, including tips and examples.
1518

@@ -38,8 +41,8 @@ For more testimonials, see [Live Projects](https://github.com/shakacode/react_on
3841

3942
## NEWS
4043

41-
* Action Cable was recently added in [PR #355](https://github.com/shakacode/react-webpack-rails-tutorial/pull/355).
42-
* We made react-native client: [shakacode/reactrails-react-native-client](https://github.com/shakacode/reactrails-react-native-client/)
44+
* Action Cable was recently added in [PR #355](https://github.com/shakacode/react-webpack-rails-tutorial/pull/355). See [PR#360](https://github.com/shakacode/react-webpack-rails-tutorial/pull/360) for additional steps to make this work on Heroku. Note, you need to be running redis. We installed the free Heroku redis add-on.
45+
* We made a react-native client: [shakacode/reactrails-react-native-client](https://github.com/shakacode/reactrails-react-native-client/). If you want to hack on this with us, [email [email protected]](mailto:[email protected]).
4346
* We have [some other open PRs](https://github.com/shakacode/react-webpack-rails-tutorial/pulls) of things we may soon be incorporating, including localization and action cable! Stay tuned! If you have opinions of what should or should not get merged, get in touch with [[email protected]](mailto:[email protected]).
4447

4548
This tutorial app demonstrates advanced functionality beyond what's provided by the React on Rails generators, mostly in the area of Webpack and React usage. Due to the architecture of placing all client side assets in the `/client` directory, React on Rails supports just about anything that Webpack and JavaScript can do, such as:

config/cable.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Action Cable uses Redis by default to administer connections, channels, and sending/receiving messages over the WebSocket.
22
production:
33
adapter: redis
4-
url: <%= ENV["REDISCLOUD_URL"] %>
4+
url: <%= ENV["REDIS_URL"] %>
55

66
development:
77
adapter: redis

config/environments/production.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
3939
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
4040

41-
# Action Cable endpoint configuration
42-
# config.action_cable.url = 'wss://example.com/cable'
43-
4441
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
4542
config.force_ssl = true
4643

@@ -85,4 +82,9 @@
8582

8683
# Do not dump schema after migrations.
8784
config.active_record.dump_schema_after_migration = false
85+
86+
# Action Cable endpoint configuration
87+
88+
config.action_cable.url = "wss://#{ENV['PRODUCTION_HOST']}/cable"
89+
config.action_cable.allowed_request_origins = ["https://#{ENV['PRODUCTION_HOST']}"]
8890
end

0 commit comments

Comments
 (0)