|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Rails Luminary nominations open, new maintenance policy and more!" |
| 4 | +categories: news |
| 5 | +author: Greg |
| 6 | +og_image: assets/images/this-week-in-rails.png |
| 7 | +published: true |
| 8 | +date: 2024-08-02 |
| 9 | +--- |
| 10 | + |
| 11 | + |
| 12 | +Hi, it is [Greg](https://greg.molnar.io), bringing you the latest changes in Rails. The framework turned 20 years old this past week. Happy Birthday Ruby on Rails! |
| 13 | +Let's explore this week's changes in the Rails codebase. |
| 14 | + |
| 15 | +[Nominations open for the 2024 Rails Luminary Awards |
| 16 | +](https://rubyonrails.org/2024/8/2/nominations-open-for-2024-luminaries) |
| 17 | +Last year the Rails Foundation started the Rails Luminary Awards acknowledging people who’ve contributed to the Rails ecosystem and community with exceptional code, documentation, enthusiasm, or assistance, thereby helping others do more, learn more, or be inspired. You can submit your 2024 Rails Luminary nomination [here](https://rails-foundation.neetoform.com/bc30089dde483e9ae9a0). |
| 18 | + |
| 19 | +[Implement new maintenance policy](https://github.com/rails/rails/pull/52471) |
| 20 | +The Rails maintenance policy was updated last week. The main changes are: |
| 21 | + - Releases are maintained by a pre-defined, fixed period of time. One year for bug fixes and two years for security fixes. |
| 22 | + - Distinction between severe security issues and regular security issues is removed. |
| 23 | + - Npm versioning is updated to match not use the pre-release - separator. |
| 24 | + |
| 25 | +[Add password reset to authentication generator](https://github.com/rails/rails/pull/52472) |
| 26 | +This pull request adds a basic password reset flow to the new Rails generator to show use of signed ids with a mailer. |
| 27 | +Also, The generator was [renamed to "authentication"](https://github.com/rails/rails/pull/52435) this past week. |
| 28 | + |
| 29 | +[Add a default password reset token to has_secure_password](https://github.com/rails/rails/pull/52483) |
| 30 | +This pull request adds a default configuration for a 15-minute password reset token when using `has_secure_password`: |
| 31 | +```ruby |
| 32 | +class User < ApplicationRecord |
| 33 | + has_secure_password |
| 34 | +end |
| 35 | + |
| 36 | +user = User.create!(name: "david", password: "123", password_confirmation: "123") |
| 37 | +token = user.password_reset_token |
| 38 | +User.find_by_password_reset_token(token) # returns user in the next 15 minutes. |
| 39 | +``` |
| 40 | + |
| 41 | +[Implement the bin/rails boot command](https://github.com/rails/rails/pull/52480) |
| 42 | +The new `bin/rails boot` command boots the application and exits. Supports the standard `-e/--environment` options. It can be handy when you want to test the boot logic of a Rails app or when benchmarking something. |
| 43 | + |
| 44 | +[Rename _check_box_ helpers to _checkbox_](https://github.com/rails/rails/pull/52432) |
| 45 | +This pull request renamed the `check_box` helper methods to `checkbox` and kept |
| 46 | +the old names as aliases. |
| 47 | +The same change was done to `text_area` in [another pull request](https://github.com/rails/rails/pull/52467). |
| 48 | + |
| 49 | +[Generate errors when running a Docker build with warnings](https://github.com/rails/rails/pull/52460) |
| 50 | +Docker introduced Docker build checks and by default, running a Docker build with warnings will not cause the build to fail (return a non-zero exit code). To raise errors on warnings `# check=error=true` declaration should be added to the Dockerfile, and this pull request did that. |
| 51 | + |
| 52 | +[Change Active Model's _human_attribute_name_ to raise an error](https://github.com/rails/rails/pull/52426) |
| 53 | +When `config.i18n.raise_on_missing_translations` is set to `true`, controllers and views raise an error on missing translations. However, models won't. This pull request changes models to raise an error when `raise_on_missing_translations` is true. |
| 54 | + |
| 55 | +[Deprecate hash key path mapping](https://github.com/rails/rails/pull/52422) |
| 56 | +This pull request deprecates drawing routes with hash key paths to make routing faster. |
| 57 | + |
| 58 | +```ruby |
| 59 | +# Before |
| 60 | +get "/users" => "users#index" |
| 61 | +post "/logout" => :sessions |
| 62 | +mount MyApp => "/my_app" |
| 63 | + |
| 64 | +# After |
| 65 | +get "/users", to: "users#index" |
| 66 | +post "/logout", to: "sessions#logout" |
| 67 | +mount MyApp, at: "/my_app" |
| 68 | +``` |
| 69 | +[Deprecate multiple path route mapping](https://github.com/rails/rails/pull/52409) |
| 70 | +Drawing routes with multiple paths was also deprecated to make routing faster. |
| 71 | +You may use `with_options` or a loop to make drawing multiple paths easier. |
| 72 | + |
| 73 | +```ruby |
| 74 | +# Before |
| 75 | +get "/users", "/other_path", to: "users#index" |
| 76 | + |
| 77 | +# After |
| 78 | +get "/users", to: "users#index" |
| 79 | +get "/other_path", to: "users#index" |
| 80 | +``` |
| 81 | + |
| 82 | +[Introduce _ActiveModel::AttributeAssignment#attribute_writer_missing_](https://github.com/rails/rails/pull/52417) |
| 83 | +This pull request introduces `ActiveModel::AttributeAssignment#attribute_writer_missing` to provide instances with an opportunity to gracefully handle assigning to an unknown attribute: |
| 84 | +```ruby |
| 85 | +class Rectangle |
| 86 | + include ActiveModel::AttributeAssignment |
| 87 | + |
| 88 | + attr_accessor :length, :width |
| 89 | + |
| 90 | + def attribute_writer_missing(name, value) |
| 91 | + Rails.logger.warn "Tried to assign to unknown attribute #{name}" |
| 92 | + end |
| 93 | +end |
| 94 | + |
| 95 | +rectangle = Rectangle.new |
| 96 | +rectangle.assign_attributes(height: 10) # => Logs "Tried to assign to unknown attribute 'height'" |
| 97 | +``` |
| 98 | + |
| 99 | +[Add _cvv_ and _cvc_ as default parameters to filter out in new apps](https://github.com/rails/rails/pull/52413) |
| 100 | +In general you should not be posting credit card details to your server, but if you make a mistake in your form and *do* post a user's credit card number, those details will get logged by default, even if your server doesn't use them. |
| 101 | +This pull request adds `cvv` and `cvc` to the defaults for [`ActiveSupport::ParameterFilter`](https://api.rubyonrails.org/v7.1.3.4/classes/ActiveSupport/ParameterFilter.html) for new apps. This means that params with those names will not get logged by default. This just changes the template for new apps; there's no changes made to existing apps. |
| 102 | + |
| 103 | + |
| 104 | +[Support Active Record batching using custom columns](https://github.com/rails/rails/pull/52384) |
| 105 | +This pull request adds support to Active Record batching to be used with custom columns. |
| 106 | +```ruby |
| 107 | +Product.in_batches(cursor: [:shop_id, :id]) do |relation| |
| 108 | + # do something with relation |
| 109 | +end |
| 110 | +``` |
| 111 | +[Reallow setting _secret_key_base_ to _nil_ in local environments](https://github.com/rails/rails/pull/52351) |
| 112 | +Previously, `secret_key_base` was allowed to be set to `nil` in local environments (or with `SECRET_KEY_BASE_DUMMY`) because validation would only happen on usage and not on the setter. This was [recently changed](https://github.com/rails/rails/commit/c2901eb084adb3d3701be157bec20d2961beb515) to make it easier to identify exactly where a _secret_key_base_ was being set to an invalid value. |
| 113 | +However, this change broke some applications which unconditionally set `secret_key_base` to some external value in dev/test. Before the change, the set value could be `nil` and fall back to the generated local secret on usage. This pull request restores that behavior. |
| 114 | + |
| 115 | +[Ensure SQLite transaction defaults to IMMEDIATE mode](https://github.com/rails/rails/pull/50371) |
| 116 | +This pull request changes Active Record to Use SQLite `IMMEDIATE` transactions when possible. With this change, transactions run against the SQLite3 adapter default to `IMMEDIATE` mode to improve concurrency support and avoid busy exceptions. |
| 117 | + |
| 118 | +_You can view the whole list of changes [here](https://github.com/rails/rails/compare/@%7B2024-07-26%7D...main@%7B2024-08-02%7D)._ |
| 119 | +_We had [31 contributors](https://contributors.rubyonrails.org/contributors/in-time-window/20240726-20240802) to the Rails codebase this past week!_ |
| 120 | + |
| 121 | +Until next time! |
| 122 | + |
| 123 | +_[Subscribe](https://world.hey.com/this.week.in.rails) to get these updates mailed to you._ |
0 commit comments