Class: MetaReports::Generators::InstallEngineGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MetaReports::Generators::InstallEngineGenerator
- Defined in:
- lib/generators/meta_reports/install_engine_generator.rb
Instance Method Summary collapse
- #create_migration_file ⇒ Object
- #install_controller ⇒ Object
- #install_model ⇒ Object
- #install_views ⇒ Object
- #mount_engine ⇒ Object
Instance Method Details
#create_migration_file ⇒ Object
10 11 12 13 14 |
# File 'lib/generators/meta_reports/install_engine_generator.rb', line 10 def create_migration_file Dir.chdir(Rails.root) do `rake meta_reports:install:migrations` end end |
#install_controller ⇒ Object
16 17 18 |
# File 'lib/generators/meta_reports/install_engine_generator.rb', line 16 def install_controller copy_file "controllers/reports_controller.rb", "app/controllers/meta_reports/reports_controller.rb" end |
#install_model ⇒ Object
20 21 22 |
# File 'lib/generators/meta_reports/install_engine_generator.rb', line 20 def install_model copy_file "models/report.rb", "app/models/meta_reports/report.rb" end |
#install_views ⇒ Object
24 25 26 |
# File 'lib/generators/meta_reports/install_engine_generator.rb', line 24 def install_views directory "views", "app/views/meta_reports/reports" end |
#mount_engine ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/meta_reports/install_engine_generator.rb', line 28 def mount_engine routes_file = "#{Rails.root}/config/routes.rb" unless open(routes_file).grep(/MetaReports::Engine/) insert_into_file(routes_file, :after => /routes.draw.do\n/) do %Q{ # This line mounts MetaReports's routes at /reports by default. # This means, any requests to the /reports URL of your application will go to MetaReports::ReportsController#index. # If you would like to change where this extension is mounted, simply change '/reports' to something different. mount MetaReports::Engine => '/reports' } end end end |