lib/rails/generators/mongoid/config/config_generator.rb in mongoid-7.2.1 vs lib/rails/generators/mongoid/config/config_generator.rb in mongoid-7.2.2
- old
+ new
@@ -13,10 +13,17 @@
def self.source_root
@_mongoid_source_root ||= File.expand_path("../templates", __FILE__)
end
def app_name
- Rails::Application.subclasses.first.parent.to_s.underscore
+ app_cls = Rails.application.class
+ parent = begin
+ # Rails 6.1+
+ app_cls.module_parent_name
+ rescue NoMethodError
+ app_cls.parent.to_s
+ end
+ parent.underscore
end
def create_config_file
template 'mongoid.yml', File.join('config', "mongoid.yml")
end