Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix Module#parent, Module#parents, and Module#parent_name with module #34051

Merged
merged 2 commits into from
Oct 2, 2018

Conversation

gmcgibbon
Copy link
Member

Summary

Adds module_ prefix to Module#parent, Module#parents, and Module#parent_name.

As discussed in #20901, parents isn't a blacklisted class attribute for model scopes. Using a parents scope will result in a SystemStackError .

An alternate approach would be to disallow parents as a valid scope name, or find a better prefix than module_ because it can include classes which are technically modules but could be better represented.

I'll look into fixing call sites once we decide what the best course of action is.

r? @rafaelfranca

/cc @dhh, @sgrif

@dhh
Copy link
Member

dhh commented Oct 2, 2018

I like this approach 👍

@rails-bot rails-bot bot added the railties label Oct 2, 2018
@rafaelfranca rafaelfranca merged commit c401c43 into rails:master Oct 2, 2018
rafaelfranca added a commit that referenced this pull request Oct 2, 2018
Prefix Module#parent, Module#parents, and Module#parent_name with module
ruby-bench-server pushed a commit to tgxworld/rails that referenced this pull request Oct 3, 2018
@gmcgibbon gmcgibbon deleted the module_parent_method_rename branch October 5, 2018 20:31
y-yagi added a commit to y-yagi/rollbar-gem that referenced this pull request Jan 25, 2019
`Module#parent_name is` deprecated in Rails 6.0.
Ref: rails/rails#34051
@cars10
Copy link

cars10 commented Mar 4, 2019

I upgraded my rails 5.2.2 app to 6.0.0.beta2 and every controller actions spams multiple of the following deprecation warnings:

.DEPRECATION WARNING: `Module#parent` has been renamed to `module_parent`. `parent` is deprecated and will be removed in Rails 6.1. (called from block in <class:ApplicationController> at /my/app/app/controllers/application_controller.rb:6)

What is the recommended way to fix these?

@kaspth
Copy link
Contributor

kaspth commented Mar 4, 2019

@cars10 reading the deprecation message it sounds like you have a parent call on line 6 of your ApplicationController that need to be renamed to module_parent.

@cars10
Copy link

cars10 commented Mar 4, 2019

I do not have any calls to parent in my entire project. Line 6 in my ApplicationController:

render json: {errors: 'Unauthorized'}, status: 401

Edit: all deprecation warnings point to lines where render is called.
Edit2: i found the cause, active_model_serializers seems to be the cause. see rails-api/active_model_serializers#2316

katsuma added a commit to katsuma/garage_client that referenced this pull request Apr 29, 2019
Suppress DEPRECATION WARNING related this PR.
rails/rails#34051
katsuma added a commit to katsuma/garage_client that referenced this pull request Apr 29, 2019
Suppress DEPRECATION WARNING related to [this changes](rails/rails#34051).
katsuma added a commit to katsuma/garage_client that referenced this pull request Apr 29, 2019
Suppress DEPRECATION WARNING related to [this changes](rails/rails#34051).
sinsoku added a commit to sinsoku/dd-trace-rb that referenced this pull request May 8, 2019
`parent_name` will be renamed `module_parent_name` in Rails 6.1,
so it displays deprecation warnings on Rails 6.0.

refs: rails/rails#34051
sinsoku added a commit to sinsoku/dd-trace-rb that referenced this pull request May 8, 2019
`parent_name` will be renamed `module_parent_name` in Rails 6.1,
so it displays deprecation warnings on Rails 6.0.

refs: rails/rails#34051
suketa added a commit to suketa/rails_sandbox that referenced this pull request Jun 15, 2019
Prefix Module#parent, Module#parents, and Module#parent_name with module
rails/rails#34051
suketa added a commit to suketa/rails_sandbox that referenced this pull request Jun 16, 2019
Prefix Module#parent, Module#parents, and Module#parent_name with module
rails/rails#34051
@leastbad
Copy link
Contributor

The marco-polo gem is also impacted by this deprecation. I created a fork that patches the function naming so as to suppress the warnings in console until such time as the upstream is updated.

https://github.com/pjforde1978/marco-polo.git

bwebster added a commit to stitchfix/stitches that referenced this pull request Sep 6, 2019
rails/rails#34051 deprecated .parent in-favor
of using .module_parent.  This commit updates the code to use the
new method, which should remove all of the deprecation warnings we
are seeing when using rails v6.
agrobbin added a commit to agrobbin/rails-erd that referenced this pull request Sep 23, 2019
…dule#module_parent`

Rails 6 deprecated `Module#parent` and friends in rails/rails#34051, replacing them with a `module_*`-prefix naming scheme. This checks to see if `module_parent` is defined, using it if it's available.
rubysamurai added a commit to rubysamurai/meta-rails that referenced this pull request Dec 14, 2020
PanosCodes added a commit to PanosCodes/mongoid that referenced this pull request Jan 5, 2021
Since Rails 6.0 the parent method is replaced with module_parent
rails/rails#34051
yagince added a commit to yagince/erd that referenced this pull request Feb 16, 2021
Rails 6 deprecated `Module#parent` and friends in rails/rails#34051, replacing them with a `module_*`-prefix naming scheme. This checks to see if `module_parent` is defined, using it if it's available.
kerrizor pushed a commit to voormedia/rails-erd that referenced this pull request Feb 16, 2021
* silence deprecation warning from the rename of `Module#parent` to `Module#module_parent`

Rails 6 deprecated `Module#parent` and friends in rails/rails#34051, replacing them with a `module_*`-prefix naming scheme. This checks to see if `module_parent` is defined, using it if it's available.

* fix tests with hacky patch

* comments

* revert formatting changes

* Fully support Rails 6.1 in tests

* forgot to exclude several old versions of Ruby

* fix indentation in blocks

Big thanks to @andrew-newell

Co-authored-by: Alex Robbin <agrobbin@gmail.com>
kennyadsl added a commit to solidusio-contrib/solidus_searchkick that referenced this pull request Apr 22, 2021
It changed in Rails with rails/rails#34051 and the old method
has been deprecated and removed. This code should work with both
Rails 5.2 and 6.1+
kennyadsl added a commit to solidusio-contrib/solidus_searchkick that referenced this pull request Apr 22, 2021
It changed in Rails with rails/rails#34051 and the old method
has been deprecated and removed. This code should work with both
Rails 5.2 and 6.1+
senid231 added a commit to senid231/didww-v3-ruby that referenced this pull request Oct 22, 2021
activesupport 6 has breaking change - parent* methods renamed to module_parent*.
see rails/rails#34051
senid231 added a commit to senid231/didww-v3-ruby that referenced this pull request Oct 26, 2021
activesupport 6 has breaking change - parent* methods renamed to module_parent*.
see rails/rails#34051
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.

None yet

6 participants