Context You want to update the same column for multiple records in one query and set different values for each record. Example: class Car < ActiveRecord::Base # has attributes: ...
Context You want to update the same column for multiple records in one query and set different values for each record. Example: class Car < ActiveRecord::Base # has attributes: ...
I was inspired to write this article by a question asked by Adrian Marin in the Twitter Ruby on Rails community and the responses I read there. https://twitter.com/adrianthedev/...
Context Let's say that you have two array of hashes: a = [ { initial: "a", email: "a@example.com" }, { email: "b@example.com", initial: "b" }, { ...
Context You need to design some routes with the following properties: you need to do some computation in the backend they are idempotent: every time you call the route with the...
Context You have a column in your table that is used as an array , like this: t.string 'ids', array: true And you want to select all records that have more than N elements i...
This is more like general advice, but when possible minimize dependencies. I will write the following examples with Ruby gems in mind but could be used in any other programming...
Context You have an array of hashes and want to check if all elements are satisfying a condition. TIL You might want to do this in Ruby: objects.all? { _1[:amount] > 10 } In th...
Quick tip about how to create a new rails project with a pre-release version of rails
If you update your Dockerfile to use ruby:3.0.3-alpine and notice the following error while building the image: ERROR: While executing gem ... (Gem::FilePermissionError) Y...
Working with DateTime or Time and timezones can be sometimes confusing. Here are some guidelines that I defined while working with dates/times. They are working well in Rails (...
You can also subscribe with RSS!