If you are using Rails muti-database feature, it's quite useful to know if you…
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
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…
I came across this change when I did a talk at Tokyo Rubyist Meetup a few months ago.
I’ve recently started seeing a trend of defining a private attr_accessor in Ruby code, and I honestly seeing them as an artifact from other programming languages. It’s something that followed the developer…
attr_accessor
I recently having a discussion with my colleague about a class variable in one of the pull request. He proposed a commit which includes a code that uses a class variable. I suggested that we should use a Thread.current to store that value instead for thread…
Thread.current
As a Rubyist, we are obsessed with our code style. That’s why tools like Rubocop exists to make sure that the project’s code style is consistent.