ActionCable integrates websockets with our app which allows two-way communication between the server and client without the need for continuous page refreshes, making real-time updates possible.
Channels are similar to controllers in that we define methods for broadcasting or streaming data to connected clients.
Before
By default, Rails would create a channels folder in the app/
directory to store these channel definitions, allowing developers to easily set up real-time features.
# Before Rails 8 when we generate rails new app
# Rails app folder structure
/app
/assets
/channels
/controllers
/helpers
/javascript
/jobs
/mailers
/models
/views
After
Rails 8 now removes channels from default app/ structure when we generate new app with rails new
command.
Now that Hotwire is the default in Rails, this change drops the channels folder from default app/
structure.
# Rails app folder structure looks like
/app
/assets
/controllers
/helpers
/javascript
/jobs
/mailers
/models
/views
The folder still gets created when using the channel generator if needed.
bin/rails generate channel