XIO

xWire

Posts from every feed QUEST has found across the web — blogs, news, podcasts, channels and more.

Ruby on Rails Discussions - Latest posts

Latest posts

[GHSA-744p-w4gc-m3gh] SQL injection through `Trilogy#escape` with multibyte encodings

GHSA-744p-w4gc-m3gh This is a vulnerability in the Trilogy library which is used by the Active Record Trilogy adapter. We believe it’s likely applications using Trilogy as their MySQL adapter are vulnerable and should upgrade immediately. This has not yet been assigned a CVE identifier, I will update the report when it is. Summary Trilogy#escape produces unsafe output for Strings in Shift_JIS, Windows-31J, Big5, GBK or GB18030. In those encodings, the continuation byte of a multi byte character…

Handling in-progress ActiveStorage variants

Interesting, I think the most useful part of that PR for this case is actually making processed? public, rather than the immediate processing option. Looks like it was merged in December 2025, though the changes are still on main for Rails 8.2, not the current 8.1 release. With 250 MB+ images, I’d be hesitant to use process: :immediately, since that means doing the variant processing during attachment. Keeping it in a background job seems like a better fit here. Once processed? is public, you…

Optimizer_hints is silently dropped from update_all and delete_all

optimizer_hints carries over to every SELECT a relation builds, but update_all and delete_all drop it without any warning: Post.optimizer_hints("INDEX(posts index_posts_on_author_id)").where(author_id: 1).update_all(title: "x") # UPDATE `posts` SET `posts`.`title` = 'x' WHERE `posts`.`author_id` = 1 where, order, limit and annotate all make it into the statement, so you expect the hint to make it in as well. The usual reason to reach for a hint is that MySQL picks the wrong plan on a big table,…

Introducing FixtureKit: fixture-speed tests without giving up FactoryBot

Hi all I’d like to share FixtureKit, a gem we built at Gusto to make our test suite faster without asking hundreds of engineers to change how they write test setup. The problem Rails fixtures are fast. Data goes into the database once, and every test runs inside a transaction that rolls back. But in a large app with thousands of models and teams with varying Rails experience, keeping a clean set of YAML fixtures isn’t realistic. So teams reach for FactoryBot. It’s readable and flexible, but it…

Redirect after form submission with result page

I have a form in my app where users can bulk edit some tag names. Once the operation is finished, I would like to display a page featuring all concrete changes to these records. When using Turbo, it requires me to redirect to some other page after form submission instead of rendering a regular HTML page with status code 200. My setup is pretty much like this: # config/routes.rb resources :tags do collection do get "bulk-edit" # use same path to prevent RoutingError in case of refresh post…

Publish the Ruby versions each supported Rails series is tested against

The Upgrading guide lists the minimum Ruby for each Rails series, but it is harder to find which newer Rubies are tested for that series. Today that information lives in rails/buildkite-config, with related policy discussed in issue comments: In rails/rails#31340, @rafaelfranca gave the rule: the newest supported Ruby is the newest one that existed when the series stopped being supported. In rails/rails#47811, @matthewd suggested publishing a recommended Ruby range per series on Ruby on Rails…

Community support: SF Ruby Conf scholarship program (free access to students and newcomers)

We’re giving away free tickets to students, recent grads, people from underrepresented groups, and those who recently changed careers and just started writing Ruby so we can continue growing the community. If you know anyone who fits, share this post with them and invite them to apply (takes 3 mins): Scholarship Program - San Francisco Ruby Conference 2026 The deadline is October 30! Note: We don’t cover travel or accommodation.

Feature proposal: Add units option to distance_of_time_in_words helper

Peer Allan: In our app we need to display the amount of time passed since an object was created in the UI. Out of the box it looks like time_ago_in_words was going to do the job. However, in our case we need to know the time in a specific unit, in this case days. By happenstance the important calculate numbers are in the 120 days range which causes time_ago_in_words to swap to ‘months’. We had to create custom method to handle this which partly duplicates the Rails code. I have a patch to…

Support PostgreSQL identity columns as the primary key generation strategy

Thank you for writing this up. I’m also interested in this. I’d like Rails to be able to create identity columns with the migration DSL, and luckily, now that Rails requires PostgreSQL 10 or later, we no longer need to handle PostgreSQL versions without identity columns. Here is one possible way to move forward. As a first step, an identity: true column option could let identity columns be created with the migration DSL and keep them in schema.rb, which is useful on its own: create_table…

Proposal: public API for correlating an association to the outer query

One reason I prefer window functions where possible is because everything is evaluated with one scan operation. So with every additional function you need then having all those multiple window functions can end up being multiple times faster than using subqueries: There are more complex examples though that window functions can’t address. In that light perhaps we can create a more involved example and see what kind of options would exist. Some kind of “reference case”. Incidentally, I have…

Proposal: public API for correlating an association to the outer query

FILTER works well for simple conditions, but if I still need the scopes elsewhere, this approach duplicates their logic in SQL strings. My example uses a very simple scope; real scopes may be more complex, and they can change over time. Once the same logic lives in both a scope and a FILTER clause (or any other raw SQL), the two can silently drift apart: it’s easy to update a scope and miss the raw SQL that’s supposed to mirror it.

Proposal: public API for correlating an association to the outer query

I suppose in that case I’d use windowing functions with FILTER, which would also mean no need for the scopes: User.left_joins(:orders).group(:id).select('users.*', 'SUM(orders.amount) FILTER(WHERE shipped_date IS NULL) AS pending_order_total', 'SUM(orders.amount) FILTER(WHERE shipped_date IS NOT NULL) AS shipped_order_total') To me having correlated subqueries managed by ActiveRecord feels quite a bit more involved. (Although using FILTER is only supported in Postgres, Sqlite, Oracle, and…

Proposal: public API for correlating an association to the outer query

Why don’t you just use a GROUP BY? That works for a single aggregate, but it breaks down for multiple aggregates. Say you want both pending and shipped totals: User.left_joins(:pending_orders, :shipped_orders) .group(:id) .select("users.*", "SUM(orders.amount)", "SUM(shipped_orders_users.amount)") This runs into a fan-out problem: the two joins multiply rows (pending × shipped), so each sum is inflated by the other’s row count. And the second join gets a Rails-generated table alias you have to…

Proposal: public API for correlating an association to the outer query

When building subqueries from associations, Active Record knows how to express an association as join constraints against its owner’s table (that’s how joins and where.associated work), but that logic isn’t exposed as a relation you can embed in another query. That makes correlated subqueries, a common and often efficient SQL pattern, awkward to write without either duplicating association logic or reaching into internals. Given: class Order < ApplicationRecord belongs_to :user scope :pending,…

Ractor Safe Rails

Update (Oct 19) A few things moved since this post. The harness is public: zoolutions/ractor-survey. It’s the app behind the numbers above, with its request runner and the one-gem survey. Each workaround has its own WA_* switch and links to its upstream fix, so every run shows exactly what it worked around. It has its own 22 requests, not the Shopify runner’s 16. From a clean clone on Ruby 4.0.7: 3 of the 22 pass with only the boot workaround on; 21 pass with all of them on. The last one calls…

Successor to `wkhtmltopdf` (& `wicked_pdf`)

Since Gotenberg has not come up yet, here is a side by side of the four options people usually weigh now. All four print with Chromium, so layout will differ a little from wkhtmltopdf’s Qt WebKit. Moving one document type at a time makes the differences easy to spot. Grover (Puppeteer from Ruby) Setup: add the gem, then npm install puppeteer, which also downloads Chromium. With a remote browser such as the browserless container mentioned above, install puppeteer-core instead and pass…

Ractor Safe Rails

Thanks for driving this. I ran the ractor-safe-rails template against an app shaped like ours (Phlex views, PostgreSQL, ~30 common gems) and wanted to share the results as data. They bear on both sides of the “which dependencies are compatible” question above. Setup: Ruby 4.0.7 and Rails main (mid-October). The app is generated from ractor_safe_rails_template.rb (load_defaults 8.2, unshareable_proc_action = :raise) with a Post scaffold, precompiled assets and a dumped db/schema_cache.yml. Each…

[Feature Proposal] Syntactic Sugar for accessing Configuration, Credentials, and ENV

Hi. I also love this idea. I strongly believe we need an abstraction layer for configuring a Rails app, not only built-in Rails configuration items but also application-specific settings. The Anyway Config gem is a great example that meets the motivation. I think Rails should natively include such a feature to organize application configs and settings, supporting various data sources like config.x, ENV, YAML, etc.

Time to get tickets to SF Ruby Conference is running out!

camimirabal: Speaking at the event: Vladimir Dementyev (Evil Martians) Chris Oliver (GoRails) Rosa Gutiérrez (37signals) Marco Roth (Herb) Jason Thomas (COSMOS) Irina Nazarova (Evil Martians) … and many more. Day 1 is all about AI, Day 2 covers queues, concurrency and open source, and Day 3 is a community day run by you. You’ll meet engineers and founders from companies like Persona (actively hiring), Gusto, Typensense, Handshake, Apple, Cisco, Anthropic, Fin, AWS,IFTTT, Workday, Zendesk,…

Range conditions on multi-column `composed_of` aggregates

Hey all, Ranges on single-mapping composed_of aggregates were fixed in https://github.com/rails/rails/pull/59013, so a value object that maps to one column now works: Customer.where(balance: Money.new(150)..Money.new(250)) # => balance BETWEEN 150 AND 250 I left out composite aggregates deliberately and wanted to discuss how they should be handled. What happens now With a value object spread over more than one column, scalar and array conditions work but a range raises: class Ingredient <…

Time to get tickets to SF Ruby Conference is running out!

We’re less than a month away from the conference and the time to get tickets is now. Speaking at the event: Vladimir Dementyev (Evil Martians) Chris Oliver (GoRails) Rosa Gutiérrez (37signals) Marco Roth (Herb) Jason Thomas (COSMOS) Irina Nazarova (Evil Martians) … and many more. Day 1 is all about AI, Day 2 covers queues, concurrency and open source, and Day 3 is a community day run by you. You’ll meet engineers and founders from companies like Persona (actively hiring), Gusto, Typensense,…

Proposal: Detect external side effects inside Active Record transactions

Hi Rails Core team, I’ve been developing TransactionGuard, a Ruby gem that detects external side effects performed inside Active Record transactions. For example, sending an HTTP request, delivering an email, or enqueueing a background job inside a transaction can create inconsistencies if the database transaction later rolls back. The external operation cannot automatically be rolled back with the database changes. TransactionGuard currently provides detection for HTTP requests, email…

What is a good database structure for products, orders, payments, and inventory in a Rails POS application?

That’s a great point! Keeping a snapshot of product details with each order makes a lot of sense, especially when products are deleted or updated later. I also like the idea of storing associated attributes as JSON to preserve the original order history. How do you handle schema changes when the product data structure evolves over time?

What is a good database structure for products, orders, payments, and inventory in a Rails POS application?

Another thing to consider in your audit trail: products come and go. If all you store is an SKU or a foreign key in the order_items, then you have no path back to “what was that product named?” It is tempting to have a place for everything, and everything in its place. But duplication is cheap, and will save future you. A more general-purpose way to handle this is gems like Audited or PaperTrail, which allow you to save all kinds of ephemera as it happens. They have their own set of problems…