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

Rails 6.1 support #1

Merged
merged 1 commit into from
Dec 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/rails_erd/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ def initialize(models = [], options = {})
# Returns the domain model name, which is the name of your Rails
# application or +nil+ outside of Rails.
def name
defined? Rails and Rails.application and Rails.application.class.parent.name
if defined? Rails && Rails.application
if rails_6_1_or_above?
Rails.application.class.module_parent_name
else
Rails.application.class.parent.name
end
end
end

# Returns all entities of your domain model.
Expand Down Expand Up @@ -167,5 +173,9 @@ def association_description(association)
def check_habtm_model(model)
model.name.start_with?("HABTM_")
end

def rails_6_1_or_above?
(Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1) || Rails::VERSION::MAJOR > 6
end
end
end