hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9K
active users

#activerecord

0 posts0 participants0 posts today

Wide Models and Active Record custom validation contexts, by @bensheldon

island94.org/2025/04/wide-mode

> This post is a brief description of a pattern I use a lot using when building features in Ruby on Rails apps and that I think needed a name:

> Wide Models have many attributes (columns in the database) that are updated in multiple places in the application, but not always all at once i.e. different forms will update different subsets of attributes on the same model.

island94.orgWide Models and Active Record custom validation contexts | Island94.org

How fast can an ActiveRecord SQL query run?, by Fritz Meissner
thoughtbot.com/blog/how-fast-c

> Your database monitoring (perhaps Amazon RDS performance insights, Skylight, or the #Postgres pg_stat_activity view) is telling you that one particular query in your Rails app is causing heavy load. Unfortunately, it already seems pretty fast. What are the odds that you can get it to run any faster?

How fast can an ActiveRecord SQL query run? by Fritz Meissner
thoughtbot · How fast can an ActiveRecord SQL query run?You have a SQL query that seems like it needs to be faster. What’s the upper-bound on improving that query’s performance?

New from Julie Kent:

Imaging you have a Rails endpoint that has slow queries AND performs third-party HTTP requests. With Rails async queries, you can perform these operations in parallel—without being an expert in multithreading. 🚀

honeybadger.io/blog/rails-asyn

Honeybadger Developer BlogRails async queries by exampleLearn the benefits of Rails async queries with Rails 7+ and the gotchas to look out for.

ok, #Rails #ActiveRecord thing:

Some people upgrading to Mastodon 4.3.0 seem to have messed up their migration relating to Active Record Encryption, by changing the secrets at some point after they first used them.

Of course since the keys have changed, the encrypted columns are irrevocably lost, and nothing can be done about that. But is there something we can do to lessen the risks of people running into that by catching the issue earlier?

Also, even overwriting those attributes is not possible in normal Rails code because save!ing will call attribute_changed? which will in turn try to decrypt the value to compare it, and raise an exception. Is there a way we can better handle columns that fail to decrypt when we are just interested in overriding them?

Today I used generated columns in SQL for the first time. These are computed columns that are updated on write and can be indexed. They work with PostgreSQL, MySQL and even SQLite.

Adding a migration via the Sequel gem was pretty straight forward. ActiveRecord has also built-in support for generated columns.

Here is a great overview about this: medium.com/the-table-sql-and-d

The Table /* SQL and devtalk */ · The Ultimate Guide to SQL Generated Columns | The Table /* SQL and devtalk */By DbVisualizer
#sql#ruby#sequel