More multi database goodies and decaffeinated Rails

Hello fellow Rubyists. This is Wojtek bringing you the latest updates from Rails.

Note about CVE gems version bumps

Usually it is enough to update vulnerable gem within the application without a need to force it in the Rails codebase.

Multi database support for schema cache dump & clear

More goodies coming for multiple databases.

Add if_not_exists option to create_table

It is now possible to silently skip adding a table if it already exists during a migration.

Add support for unlogged PostgreSQL tables

If you ever wanted to create unlogged tables, now you can.

Convert CoffeeScript to JavaScript

So Rails is having fewer sips of coffee these days and of course never indulged in those dark blends of Java 😄.

37 people contributed to Rails within latest two weeks. Check out the full list of changes.

Special wishes to all RubyConf attendees ❤️. Until next time.

Webpacker, Action Text, Multiple database improvements, and more

Boo! It’s Daniel here, bringing you news about Rails for October. 🎃

Make Webpacker the default JavaScript compiler for Rails 6

Less than two years ago Rails introduced the Webpacker gem, making it easy to manage JavaScript with webpack. We started October strong by merging a whole bunch of commits by a number of people to make Webpacker the default for Rails 6.

Introducing Action Text

Combining the powers of Active Storage, Webpacker, and Trix, Action Text brings rich text content and editing to Rails. Check it out!

Improvements for multiple databases

In part 4 of the series, Eileen adds connects_to and connected_to. Stay tuned for the next episode!
We also got multi-db support for db:migrate:status. I like the approach of making the change easy, then making the change.

Support default expression and expression indexes for MySQL

With the release of MySQL 8.0.13, we can now support functions and expressions as default values, and functional key parts that index expression values rather than column or column prefix values.

Add guides section on verbose query logs

Why spend time tracking down which line of your code is triggering a database query when Active Record can just tell you? Well you might do just that if you don’t know about the verbose_query_logs option. Luckily we now have a section in our guides describing the option in detail.

Document deep_interpolation parameter for bulk lookups

This is a fun option I didn’t know existed. There is something mildly foreboding about the name deep_interpolation, I think. Anyway, our I18n guide now documents it.

Show allocations for template and partial rendering

_Completed 200 OK in 858ms (Views: 848.4ms ActiveRecord: 0.4ms _ Allocations: 1539564 ) 🙂

Fix autoloading issue with Active Storage

This brave soul wandered into dependencies.rb and made it to the other side. Bravo!

Preparing Rails for winter

As the weather gets colder here in New York, I am glad I don’t need to be reminded of how freezing I am whenever I look through the Rails codebase.

77 people contributed to Rails since our last issue. There are also 77 partitions for the number 12. Spooky coincidence? I think so.

Check out the full list of changes.  If you are interested in contributing, we have plenty of open issues. I hope to see your name on the list next week!

Introducing Action Text for Rails 6

Action Text is a brand new framework coming to Rails 6 that’s going to make creating, editing, and displaying rich text content in your applications super easy. It’s an integration between the Trix editor, Active Storage-backed file and image processing, and a text-processing flow that ties it all together. With Action Text, you really shouldn’t ever have to impoverish your users with a vanilla textarea ever again!

Rails 6 is still a long ways off – we’re hoping to start the beta process in early 2019 – but Action Text is already in pretty decent shape. Yes, this is an alpha preview, and we haven’t even merged it into rails/rails yet, but it’s a release that’s been extracted from the code we’ve been using to power rich text editing in Basecamp 3 for several years now.

The Trix editor itself just turned 1.0, and is the product of endless craftwork by Sam Stephenson and Javan Makhmali. Both of whom also worked on Action Text to extract our Basecamp wrapping into this reusable package.

As part of this introduction, I’ve recorded a brief video showing how Action Text works with a sample application. Do check it out, and if you’re interested, now is a great time to get involved helping to shape a major new framework in Rails.

Rails 6 really is shaping up to be a major release. Besides Action Text, we’ve been cooking several other new frameworks in Basecamp 3 that we hope to extract. On top of all the wonderful work coming from others in the community, like the multi-db and parallel testing extractions that the team at GitHub are responsible for. This is a great time to be in Rails!

Multi env credentials support, Action Cable channel unit testing and more!

Hello everyone! This is Prathamesh from Pune, India bringing you the latest news from the Rails world.

Multi environment support for credentials

Now it is possible to have credentials for each environment. If the file for current environment exists it will take precedence over config/credentials.yml.enc. For eg. production environment looks for
config/credentials/production.yml.enc first.

Support for unit testing Action Cable channels

This change introduced ActionCable::Channel::TestCase  which provides an ability to unit test channel classes.

Raise error when using recyclable cache keys using a store which does not support it

Some cache stores do not support recyclable cache keys. This can lead to generating the cache entries which never invalidate.

This change adds a check to ensure that if recyclable cache keys are being used then the cache store needs to show that it supports this versioning scheme. 

Improvements to migration paths of multiple databases

This change adds an option to specify the migrations paths while generating the models.

bin/rails g model Room capacity:integer –migrations-paths=db/kingston_migrate

Additionally, a shortcut database option is added which uses the database configuration for the current environment.

Eagerly define attribute methods in production

The attribute methods for a model are currently defined lazily the first time that model is instantiated, even when config.eager_load is true.

Now they are defined while the app is booted to save the database round trip costs. There is related discussion and a pull request to do this change only when schema cache exists.

Ignore psqlrc files when executing psql commands within Rails

.psqlrc files can affect the execution of commands that can hold up execution by blocking or cause side effects.

Rails ignores it now by using -X option.

It is also ignored while loading structure.sql file for PostgreSQL databases by Rails.

Add a way to check for subset of arguments when performing jobs

The arguments need to match exactly what the job get passed when calling assert_performed_with / assert_enqueued_with

This change makes it possible to only check if a subset of arguments were passed to the job. Handy when you have too many arguments for the job.

50 people contributed to Rails over the past two weeks. Check out the full list of changes. If you are interested in helping out, we have plenty of open issues. I hope to see your name on the list next week!

Performance improvements, configuration options, and more

Greetings! Daniel here, reporting from Brooklyn, NY.

Use faster globs for template resolving

Resolving templates used to get pretty slow as the number of view paths, handlers, and formats increased. Replacing 1682 system calls with 14 sounds pretty great to me!

Do less work and use less memory

2.4% faster, 1.7% faster, 1.58% faster. Many thanks to Richard for working hard so our applications don’t need to!

Improve performance of Integer#multiple_of?

With a few clever tweaks, it has never been easier to find out if 4611686018427387903 is a multiple of 42.

Default to utf8mb4 for MySQL

The previous default character set did not support supplemental characters like emoji. The 4-Byte utf8mb4 has you covered. 👍 

Introduce model-level configuration for filtering sensitive attributes

Nobody wants sensitive data to show up in logs. The new filter_attributes setting allows you to filter out sensitive attributes when calling a model’s inspect method.

Introduce configurable prefix for Active Storage routes

By default the Active Storage routes begin with
/rails/active_storage. If that doesn’t suit you, you can now use any scope you like by setting config.active_storage.routes_prefix in your application config.

Include an id in Action Cable’s Redis configuration

Action Cable now passes an id to Redis, which can help you distinguish between Action Cable’s connection and any other connections you might have.

44 people contributed to Rails over the past two weeks. Check out the full list of changes. If you are interested in helping out, we have plenty of open issues. I hope to see your name on the list next week!

Read replica database configurations, faster parameter filtering, and more!

Hello everyone! This is Eugene, bringing you the highlights from the last week of activity in the Rails codebase.

Add hooks to Active Job on retries and discards

Your application can now subscribe to be notified whenever a job is retried or discarded. Neat!

Support read replica database configurations

Database configurations can now be flagged as “replicas”, indicating that the database they connect to is read-only.

For now this just means they’re ignored by database tasks like db:create, but the comments on the pull request mention some other features that could be built on top of this change.

Reduce allocations during parameter filtering

Initially this patch looked like a micro-optimisation, but the author produced a benchmark which demonstrated saving 1% of both memory and time on a real world Rails app.

Find inverse associations with plural names

Previously, inverse associations would only be detected when they matched the model name exactly. Now, the case where they use the plural form of the model name will work too.

Clear mutation tracker after yielding in around callbacks

This change ensures that a record’s view of the database is up to date immediately after an around callback yields, just as it would be in an after callback.

21 people contributed to Rails this week; feel free to check out the full list of changes. If you want help out, maybe look for an interesting open issue?

Until next time!

Action Cable testing utilities, bugfixes and more!

Happy Sunday! This is Greg bringing you the latest news about Rails.

The initializers Rake task is moved to Rails::Command

Another Rake task is moved to Rails::Command, so in Rails 6 you will need to call bin/rails initializers instead of bin/rake initializers.

Improve Active Job test helpers

This change adds a queue option to perform_enqueued_jobs, and if it is set, only the specified queue will be performed.

Fix rails routes -c

This PR fixes the issue of rails routes -c UserPermissionsController did not output routes for the corresponding controller, because its name consists of multiple words. 

Action Cable testing

This PR is basically a merge of the actioncable-testing gem into Rails, to provide testing utilities for Action Cable.

Fail more gracefully from Active Storage missing file exceptions

This PR translates service-specific missing object exceptions into one generic ActiveStorage::FileNotFoundError, so the application can fail more gracefully when a missing file is accessed.

Omit BEGIN/COMMIT statements for empty transactions

With this change, if a transaction is opened and closed without any queries being run, the BEGIN and COMMIT statements are omitted to remove the overhead, and make workarounds like save if changed? unnecessary.

Support multiple submit buttons in Active Storage forms

Often times forms have more than one submit button enabling different actions, but before this change, Active Storage used the first submit button of the form, rather than the one the user actually clicked.

28 people contributed to Rails this week. If you also want help out, check out the list of open issues! Until next time!

Cookies with purpose, Array extract! and more

Welcome in this week news edition from Rails world. This is Wojtek bringing you summary of latest activities.

Once Webpacker is the default in rails/master, we’ll be unveiling the alpha version of a brand-new exciting framework for Rails 6.0 😄.

If you can’t wait, help us testing Webpacker integration so it can be merged and mystery revealed.

Add Purpose Metadata to Cookies

Adds purpose metadata to cookies so that the value of one cookie cannot be copied and used as the value of another cookie.

Add Array#extract!

The method removes and returns the elements for which the block returns a true value.

numbers = [1, 2, 3, 4]
odd_numbers = numbers.extract!(&:odd?) # => [1, 3]
numbers # => [2, 4]

Replace rake dev:cache with Rails command

Rake task is now deprecated in favor of “rails dev:cache”

24 people contributed to Rails this week. You can see all the changes here.
Until next time!

Rails 5.2.1, skip caching nil entries and more

Namaste everyone! This is Prathamesh bringing you the latest news from the Rails world with some rain and chai from Pune.

Rails 5.2.1 is out in the wild

Rails 5.2.1 is released. Give it a try and check out all the awesome features.

Better error handling of Active Storage adapters

Now, the Active Storage service adapter names can be lower case or upper case. Also, a nice error message is printed if the service adapter class can’t be loaded.

Support for skipping caching of nil entries

While caching data from external services, sometimes we may get nil values. Most probably we don’t want to cache them. Here is an option skip_nil: true/false to skip caching of such entries.

Fix the issue of build not getting called on extension for has_many association

Earlier, the extended build method was not called properly for the has_many association which was being accepted by using accepts_nested_attributes_for.

This issue is fixed now.

19 people contributed to Rails this week. Four of them contributed for the first time! Do you also want to join them? There might be some open issues you can try tackling?

See all the changes  from last week here and stay tuned for next week. 👋

Rails 5.2.1 has been released!

Hi everyone,

I am happy to announce that Rails 5.2.1 has been released.

CHANGES since 5.2.0

To view the changes for each gem, please read the changelogs on GitHub:

Full listing

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-256 hashes.

Here are the checksums for 5.2.1:

$ shasum -a 256 *-5.2.1.gem
ce0d3cf1c76afd3a2f8a751542e2ddfe48cf4005d426a09775b944a780ed6d9f  actioncable-5.2.1.gem
a667ecf76d300a8faebc5125c25ddb4e46d9c96496c206eee7e02a79c8c33640  actionmailer-5.2.1.gem
8eb8407ad4c836c46285720b05fa7600bec0327fddc3127b43edf2987a4cfba7  actionpack-5.2.1.gem
ae45abf777e829e31c6d3a66f43ed792a657b91fe9b5f322f1f63e7bb4b4aa37  actionview-5.2.1.gem
79383a8dad75cf39677a0096109fc9dcf61cfcf1ef39aeddf2347486c03f94d4  activejob-5.2.1.gem
a45939b9b0e23225d81786519dda2f1ba9f1568012682aa344d8b1e154b77610  activemodel-5.2.1.gem
ef3c520c782d5e51ee67231d4b6167db0166d4b451d0c835e0577eb89967875d  activerecord-5.2.1.gem
4ff9bba1a317bfbc5cd9349bb4e00f6e0aff76d237d68a71ad524b92e0c8cc72  activestorage-5.2.1.gem
829a480f2cf3747b5e94429d983dfb1645a27d506b365642d08ecc3066373e7e  activesupport-5.2.1.gem
776cfea45140972f1780236748f7cfe72cf95c032056812128433273c366078c  rails-5.2.1.gem
1ba71ee5ec7d85567f9984df1dae2eb7e6c8c2855e6b810582719fb5db20c3a7  railties-5.2.1.gem

As always, huge thanks to the many contributors who helped with this release.