Class: Madmin::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Madmin::Generators::InstallGenerator
show all
- Includes:
- Madmin::GeneratorHelpers
- Defined in:
- lib/generators/madmin/install/install_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
#copy_controller ⇒ Object
14
15
16
|
# File 'lib/generators/madmin/install/install_generator.rb', line 14
def copy_controller
template("controller.rb.tt", "app/controllers/madmin/application_controller.rb")
end
|
#eager_load ⇒ Object
10
11
12
|
# File 'lib/generators/madmin/install/install_generator.rb', line 10
def eager_load
Rails.application.eager_load!
end
|
#generate_resources ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/generators/madmin/install/install_generator.rb', line 31
def generate_resources
generateable_models.each do |model|
if model.table_exists?
call_generator "madmin:resource", model.to_s
else
puts "Skipping #{model} because database table does not exist"
end
end
end
|
#generate_routes ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/generators/madmin/install/install_generator.rb', line 18
def generate_routes
if rails6_1_and_up?
route "draw :madmin", file: ROUTES_FILE[:default]
template("routes.rb.tt", "config/routes/madmin.rb")
end
if route_namespace_exists?
route "root to: \"dashboard#show\"", indentation: separated_routes_file? ? 2 : 4, sentinel: /namespace :madmin do\s*\n/m
else
route "root to: \"dashboard#show\"", namespace: [:madmin]
end
end
|