Class: Madmin::Generators::ResourceGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Madmin::Generators::ResourceGenerator
show all
- Includes:
- Madmin::GeneratorHelpers
- Defined in:
- lib/generators/madmin/resource/resource_generator.rb
Constant Summary
Madmin::GeneratorHelpers::ROUTES_FILE
Instance Method Summary
collapse
#call_generator, #optimize_indentation, #rails6_1_and_up?, #route, #route_namespace_exists?
Instance Method Details
#eager_load ⇒ Object
8
9
10
|
# File 'lib/generators/madmin/resource/resource_generator.rb', line 8
def eager_load
Rails.application.eager_load!
end
|
#generate_controller ⇒ Object
16
17
18
19
|
# File 'lib/generators/madmin/resource/resource_generator.rb', line 16
def generate_controller
destination = Rails.root.join("app/controllers/madmin/#{file_path.pluralize}_controller.rb")
template("controller.rb", destination)
end
|
#generate_resource ⇒ Object
12
13
14
|
# File 'lib/generators/madmin/resource/resource_generator.rb', line 12
def generate_resource
template "resource.rb", "app/madmin/resources/#{file_path}_resource.rb"
end
|
#generate_route ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/generators/madmin/resource/resource_generator.rb', line 21
def generate_route
if route_namespace_exists?
route "resources :#{plural_name}", namespace: class_path, indentation: separated_routes_file? ? 2 : 4, sentinel: /namespace :madmin do\s*\n/m
else
route "resources :#{plural_name}", namespace: [:madmin] + class_path
end
end
|