Articles in this series
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 this case, you should remember according to with the documentation .all? mi...
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 in the array Solution In PostgreSQL, you can use cardinality to achieve ...
Context Let's say that you have two array of hashes: a = [ { initial: "a", email: "a@example.com" }, { email: "b@example.com", initial: "b" }, { initial: "c", amount: 3, email: "c@example.com" } ] and b...
How to create a raw SQL to update in Rails different values for each record in one single query