Saturday, September 17, 2022

Handling reconnects in Action Cable, no more Coffeescript and a new guide.

Posted by petrik

Hi, this is Petrik with this week’s Rails updates and some Hotwire news.

Add exclude? method to ActionController::Parameters

exclude? returns true if the given key is not present in the parameters. It is the inverse of include?. Adding this method keeps things a little more consistent with a Hash.

params = ActionController::Parameters.new(id: 1)
params.exclude?(:name) # => true
params.exclude?(:id) # => false

Add ability to handle reconnects with the connected callback

If a subscriber misses some messages when the connection is lost, this allows them to handle reconnects with the connected() callback.

consumer.subscriptions.create("ExampleChannel", {
  connected({reconnected}) {
    if (reconnected) {
      ...
    }
    else {
      ...
    }
  }
});

Add Puma to an engine’s Gemfile

With the removalof WEBrick from the Ruby standard library, the dummy application in an engine would not start. Adding Puma to the Gemfile makes sure it works out-of-the-box.

Add ssl-mode option to dbconsole command and MySQLDatabaseTasks

For MySQL, verifying the identity of the database server requires setting the ssl-mode option to VERIFY_CA or VERIFY_IDENTITY. This option was previously ignored for the dbconsole command and database tasks like creating a database.

Convert rails-ujs to ES2015 modules

The rails-ujs code base was the only Coffeescript left in the Rails code base. It has now been migrated to use ES2015 modules and Rollup instead.

Add the Error Reporter Guide In Rails 7.0 an error reporter interface was introduced. It provides a generic interface to report errors, with an adapter API to allow using the service of your choice. It now has its own guide!

Rails had 23 contributors since last week.

In the Hotwire world there was a new release for Turbo this week:  v7.2.0-rc.2.

That’s it for this week!

Subscribe to get these updates mailed to you.