If you are using Rails muti-database feature, it's quite useful to know if you…
So I have this ~/.aliases file in my home directory that contain all of my aliases. However, everytime I open the file I have to do :set filetype=bash to make Vim syntax highlight my file … until today!
TL;DR: Hash#fetch is now faster than doing [] || in Ruby 3.1+.
So, you should be fine using #fetch with default value anywhere now!
As of Ruby 2.5.1, double splat operator (**options, for example) is still considerably slower than accepting a normal argument and sets a default to empty hash.
**options
This one is a simple quality-of-life improvement.
In Rails 6.0, rails routes command will support --expanded (or -x, the shorthand version). This is similar to \x mode in psql where it will print the record in detailed list instead of in a table.
rails routes
--expanded
-x
\x
psql
$ rails routes --expanded--[ Route 1…
Back in 2012, Rails 3.2.0 added a .pluck method which you can call on a ActiveRecord::Relation or a model class:
.pluck
ActiveRecord::Relation
> User.pluck(:id)#=> [1, 2, 3]
But what if you need just the first value from the result? You will probably have to…