Nov 25, 2024 · 5 min read · As applications grow in scale, database performance often becomes a critical bottleneck. Ruby on Rails, with its ActiveRecord ORM, offers powerful tools to simplify database interactions. However, without proper optimizations, these conveniences can ...
Join discussion
Nov 7, 2024 · 4 min read · A few weeks ago I was working on modelling set of relationships between very similar concepts so I evaluated the different alternatives that Active Records provides for this; Abstract classes, Single Table Inheritance (STI) and Delegated Types. I end...
Join discussionOct 24, 2024 · 1 min read · Vamos pensar no cenário em que eu possuo uma Model Customer e eu pretendo retorna-lá como JSON em alguma parte da minha aplicação: class Customer include ActiveModel::Model attr_accessor :id, :name validates :id, presence: true, numericality: ...
Join discussionJun 28, 2023 · 3 min read · The following Active Record query: User.where(created_at: 1.day.ago...Time.current).to_sql will generate this SQL: SELECT "users".* FROM "users" WHERE "users"."created_at" >= '2023-06-21 06:38:26.330063' AND "users"."created_at" < '2023-0...
Join discussion
Sep 6, 2021 · 1 min read · If you have a jsonb field in your Active record object and you want some nested value you can use pluck Example: Lets say your Users model has a jsonb attribuite metadata which has a nested key location which in turn has city you can get the value of...
Join discussion