Skip to content

Deprecate ActiveSupport::Configurable#53970

Merged
rafaelfranca merged 1 commit intorails:mainfrom
seanpdoyle:deprecate-active-support-configurable
Jan 7, 2025
Merged

Deprecate ActiveSupport::Configurable#53970
rafaelfranca merged 1 commit intorails:mainfrom
seanpdoyle:deprecate-active-support-configurable

Conversation

@seanpdoyle
Copy link
Contributor

Motivation / Background

This proposal is based on a code review comment:

I think we should deprecate and remove this module. It is only used
once inside the framework, in a place that perhaps don't even need it
anymore and I don't think it adds much for our users. They would be
better served with their own config object that is just a hash.

Detail

To achieve this outcome, replace the only internal occurrence of ActiveSupport::Configurable with a class_attribute. Similarly, replace config_accessor calls with class- and instance-level calls to delegate for the readers and writers.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@seanpdoyle seanpdoyle force-pushed the deprecate-active-support-configurable branch 2 times, most recently from 7052681 to 83d5a2e Compare December 15, 2024 18:04
This proposal is based on a [code review comment][]:

> I think we should deprecate and remove this module. It is only used
> once inside the framework, in a place that perhaps don't even need it
> anymore and I don't think it adds much for our users. They would be
> better served with their own config object that is just a hash.

To achieve this outcome, replace the only internal occurrence of
`ActiveSupport::Configurable` with a [class_attribute][]. Similarly,
replace [config_accessor][] calls with class- and instance-level calls
to [delegate][] for the readers and writers.

[code review comment]: rails#53796 (comment)
[class_attribute]: https://edgeapi.rubyonrails.org/classes/Class.html#method-i-class_attribute
[config_accessor]: https://edgeapi.rubyonrails.org/classes/ActiveSupport/Configurable/ClassMethods.html#method-i-config_accessor
[delegate]: https://edgeapi.rubyonrails.org/classes/Module.html#method-i-delegate
@janko
Copy link
Contributor

janko commented Nov 11, 2025

I feel like just mentioning class_attribute as an alternative isn't enough, because it's easy to create a configuration that's unintentionally shared across subclasses. For example, active_model_serializers gem currently has this bug after rails-api/active_model_serializers#2492, because they haven't also defined an inherited with ActiveSupport::InheritableOptions like was done in this PR.

benilovj added a commit to benilovj/govuk-form-builder that referenced this pull request Nov 17, 2025
This has been deprecated in Rails 8.1, and although it is still
available until 8.2, replacing its usage now removes a deprecation
warning. Follows an approach similar to
rails/rails#53970.
jho406 added a commit to thoughtbot/humid that referenced this pull request Dec 21, 2025
For context see rails/rails#53970. We're also moving
away from a top level module to class and use a version constraint for the
supported rails versions only.
jho406 added a commit to thoughtbot/humid that referenced this pull request Dec 21, 2025
For context see rails/rails#53970. We're also moving
away from a top level module to class and use a version constraint for the
supported rails versions only.
jho406 added a commit to thoughtbot/humid that referenced this pull request Dec 21, 2025
For context see rails/rails#53970. We're also moving
away from a top level module to class and use a version constraint for the
supported rails versions only.
@freesteph
Copy link

I don't think deprecating this module was a fantastic idea; it provided a really nice interface to implement a very common pattern, and the starting point:

This proposal is based on a #53796 (comment):

I think we should deprecate and remove this module. It is only used
once inside the framework, in a place that perhaps don't even need it
anymore and I don't think it adds much for our users. They would be
better served with their own config object that is just a hash.

seems to overlook the 7.5k files yielded by a search for include ActiveSupport::Configurable across GitHub.

Besides the rather terse message mentioned in the previous comment, the few PRs I've looked that address the deprecation end up with code that is arguably harder to read/understand.

Could we reconsider the deletion/deprecation of Configurable? It think it was a legitimate part of ActiveSupport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants