|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Active Job Continuations and more" |
| 4 | +categories: news |
| 5 | +author: Wojtek |
| 6 | +og_image: assets/images/this-week-in-rails.png |
| 7 | +published: true |
| 8 | +date: 2025-05-30 |
| 9 | +--- |
| 10 | + |
| 11 | + |
| 12 | +Hi, [Wojtek](https://x.com/morgoth85) here. Let's see this week's news about Rails. |
| 13 | + |
| 14 | +[Final RailsConf](https://rubyonrails.org/2025/5/29/final-railsconf) |
| 15 | +The last RailsConf (July 8 - 10, Philadelphia) will include a fireside chat with DHH, and talks or panel discussions with Rails team members Eileen Uchitelle (Core), Gannon McGibbon (Committers), Hartley McGuire (Issues), and Matheus Richard (Triage), as well as many more new and familiar faces. [Tickets are still available](https://railsconf.org/). |
| 16 | + |
| 17 | +[Introduce Active Job Continuations](https://github.com/rails/rails/pull/55127) |
| 18 | +Allow jobs to the interrupted and resumed with Continuations. |
| 19 | + |
| 20 | +A job can use Continuations by including the *ActiveJob::Continuable* concern. Continuations split jobs into steps. When the queuing system is shutting down jobs can be interrupted and their progress saved. |
| 21 | + |
| 22 | +```ruby |
| 23 | +class ProcessImportJob |
| 24 | + include ActiveJob::Continuable |
| 25 | + |
| 26 | + def perform(import_id) |
| 27 | + @import = Import.find(import_id) |
| 28 | + |
| 29 | + # block format |
| 30 | + step :initialize do |
| 31 | + @import.initialize |
| 32 | + end |
| 33 | + |
| 34 | + # step with cursor, the cursor is saved when the job is interrupted |
| 35 | + step :process do |step| |
| 36 | + @import.records.find_each(start: step.cursor) do |record| |
| 37 | + record.process |
| 38 | + step.advance! from: record.id |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + # method format |
| 43 | + step :finalize |
| 44 | + |
| 45 | + private |
| 46 | + def finalize |
| 47 | + @import.finalize |
| 48 | + end |
| 49 | + end |
| 50 | +end |
| 51 | +``` |
| 52 | + |
| 53 | +[Remove unnecessary ruby-version input from GitHub Actions template](https://github.com/rails/rails/pull/55120) |
| 54 | +*.ruby-version* file is tried first by default by the *ruby/setup-ruby* action. |
| 55 | + |
| 56 | +[Memoize successful reflection cache validation](https://github.com/rails/rails/pull/55115) |
| 57 | +Association reflections are objects that store metadata about an association. |
| 58 | +Once an association has been defined, it is all set, the association cannot be mutated, and the reflection should not be mutated either. |
| 59 | +This provides a performance improvement. |
| 60 | + |
| 61 | +[rails-dom-testing v2.3.0 released](https://github.com/rails/rails-dom-testing/releases/tag/v2.3.0) |
| 62 | +It brings a handy new assertion `assert_not_dom` that can be used in app integration tests. |
| 63 | + |
| 64 | +_You can view the whole list of changes [here](https://github.com/rails/rails/compare/@%7B2025-05-23%7D...main@%7B2025-05-30%7D)._ |
| 65 | +_We had [10 contributors](https://contributors.rubyonrails.org/contributors/in-time-window/20250523-20250530) to the Rails codebase this past week!_ |
| 66 | + |
| 67 | +Until next time! |
| 68 | + |
| 69 | +_[Subscribe](https://world.hey.com/this.week.in.rails) to get these updates mailed to you._ |
0 commit comments