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

module_parent vs parent #358

Open
ciembor opened this issue Jul 30, 2020 · 4 comments
Open

module_parent vs parent #358

ciembor opened this issue Jul 30, 2020 · 4 comments

Comments

@ciembor
Copy link

ciembor commented Jul 30, 2020

Rails version: Rails 6.0.2.1

Error:

Failed: ActiveSupport::DeprecationException: DEPRECATION WARNING: 'Module#parent' has been renamed to 'module_parent'. 'parent' is deprecated and will be removed in Rails 6.1.

Solution: in lib/rails_erd/domain.rb:52 replace Rails.application.class.parent.name with Rails.application.class.module_parent.name. But...

Rails version: Rails 5.2.4.3

In this version rails-erd works, but it doesn't with changed code:

Failed: NoMethodError: undefined method 'module_parent'

I think rails-erd is very usefull also in old projects, during takeover by new developers. Solution would be to handle both cases, maybe using respond_to? or to get this name in a different way.

@ciembor
Copy link
Author

ciembor commented Jul 30, 2020

We can use:

if Rails::VERSION::MAJOR >= 6
  Rails.application.class.module_parent.name
else
  Rails.application.class.parent.name
end

This is the cleanest way to handle this. We can also use partition:

Rails.application.class.name.partition('::').first

@gee-forr
Copy link

gee-forr commented Nov 9, 2020

I can confirm it's not working. Running Rails 6.1 rc1 and I'm getting this when I attempt to generate an ERD:

Loading application environment...
Loading code in search of Active Record models...
Generating Entity-Relationship Diagram for 35 models...
rails aborted!
NoMethodError: undefined method `parent' for SomeRandomApp::Application:Class
Did you mean?  present?
/app/bin/rails:4:in `require'
/app/bin/rails:4:in `<top (required)>'
/app/bin/spring:7:in `require'
/app/bin/spring:7:in `block in <top (required)>'
/app/bin/spring:4:in `tap'
/app/bin/spring:4:in `<top (required)>'
/app/config/boot.rb:4:in `load'
/app/config/boot.rb:4:in `<top (required)>'
Tasks: TOP => erd => erd:generate

@gee-forr
Copy link

It looks like there's been a PR that will resolve this #345 from September 2019. It's CI builds are failing though :(

ChrisMacNaughton added a commit to CentauriSolutions/EyeDP that referenced this issue Jan 12, 2021
Until voormedia/rails-erd#358 is resolved,
rails-erd cannot generate ERD data from the models on Rails 6.1.

This patch reoslves the above by monkey-patching in a fix that has
been proposed upstream.
ChrisMacNaughton added a commit to CentauriSolutions/EyeDP that referenced this issue Jan 14, 2021
* A user can have custom attributes

The user can edit their own attributes and an admin can update these
attributes.

* A group can have custom properties

In addition to adding functionality for a group to have custom
properties, this change includes additional admin controllers
and views to manage the newly created models.

Closes #48

* Monkey patch rails_erd to work with Rails 6.1

Until voormedia/rails-erd#358 is resolved,
rails-erd cannot generate ERD data from the models on Rails 6.1.

This patch resolves the above by monkey-patching in a fix that has
been proposed upstream.

This also ended up with some tidying of Rubocop config as
a result of needing to update it for the new concern spec.
@homonecloco
Copy link

This seems to be solved by #365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants