This Week in Rails

September 17, 2022

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

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

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

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 {
      ...
    }
  }
});

With the removal of 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.

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.

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!