With #RubyOnRails, you can check an #ActiveRecord object’s validations on an attribute using `object.class.validators_on(attribute)`.

The result is an array of validator classes, most of which include an `options` method with the configured options from the definition in the model.

Is it possible to filter out conditional validations from the returned array?

(I have a conditional validation on an attribute and would like to know when it doesn’t apply to a particular instance of the model.)

⏰ Just one hour away, our June online meetup is starting ⏰
Join us today at 12pm Eastern for An ActiveRecord Rewrite: the Story Behind the Attributes API talk from Tess Griffin! Find us and the meetup link on discord: https://discord.gg/KfBeRSjK?event=1384536117914894458

#online #meetup #ruby #rails #activerecord

Join the WNB.rb Discord Server!

Check out the WNB.rb community on Discord - hang out with 202 other members and enjoy free voice and text chat.

Discord

JRuby's activerecord-jdbc-adapter doesn't yet support ActiveRecord 8. How should a gem which depends on ActiveRecord try to best support both CRuby and JRuby?
https://rubygems.org/gems/activerecord-jdbc-adapter/versions/71.0-java

#activerecord #jruby

Depend on activerecord >= 7.0.0, < 9.0.0
20%
Add a jruby-specific AR ~> 7.1 dependency
80%
Poll ended at .
activerecord-jdbc-adapter | RubyGems.org | your community gem host

A Can of Shardines: SQLite Multitenancy With Rails

There is a pattern I am very fond of - “one database per tenant” in web applications with multiple, isolated users. Recently, I needed to fix an application I had for a long time where this database-per-tenant multitenancy utterly broke down, because I was doing connection management wrong. Which begat the question: how do you even approach doing it right? And it turns out I was not alone in this. The most popular gem for multitenancy - Apartment - which I have even used in my failed startup back in the day - has the issue too. The culprit of does not handle multithreading very well is actually deeper. Way deeper. Doing runtime-defined multiple databases with Rails has only recently become less haphazard, and there are no tools either via gems or built-in that facilitate these flows. It has also accrued a ton of complexity, and also changes with every major Rails revision. TL;DR If you need to do database-per-tenant multitenancy with Rails or ActiveRecord right now - grab the middleware from this gist and move on. If you are curious about the genesis of this solution, strap in - we are going on a tour of a sizeable problem, and of an API of stature - the ActiveRecord connection management. Read on and join me on the ride! Many thanks to Kir Shatrov and Stephen Margheim for their help in this.

Julik Tarkhanov

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

https://island94.org/2025/04/wide-models-and-active-record-custom-validation-contexts

> 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.

#ruby #ActiveRecord

Wide Models and Active Record custom validation contexts | Island94.org

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

> 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?

#ruby #SQL #ActiveRecord

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?

thoughtbot

It's always great to see @rosa and she talked about her #SolidQueue implementation at #rubycommunityconference in #krakow.

She also gave a shout-out to @bensheldon's #goodjob and mentioned how @getajobmike's @sidekiq is blazingly fast.

#ruby #rails #queue #rubyonrails #activerecord #poland #37signals #backgroundprocessing #backgroundprocesses #sidekiq

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. 🚀

https://www.honeybadger.io/blog/rails-async-queries/?utm_source=mastodon&utm_medium=social

#Ruby #RubyOnRails #ActiveRecord #Performance #Programming

Rails async queries by example

Learn the benefits of Rails async queries with Rails 7+ and the gotchas to look out for.

Honeybadger Developer Blog
I know #SQLite3 supports #SQL comments in newer versions with the right flags, but `rails g` for #ActiveRecord ďoesn’t seem to support them except in #PostgreSQL or #MySQL / #MariaDB. Is there a workaround?