module Panel class InstallGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) def add_route insert_into_file 'config/routes.rb', after: /(.*)::Application.routes.draw do/ do |match| "#{match}\n\n namespace :panel do\n root to: 'pages#index'\n end" end end def add_templates template 'install/base_controller.rb', 'app/controllers/panel/base_controller.rb' template 'install/pages_controller.rb', 'app/controllers/panel/pages_controller.rb' template 'install/index.html.erb', 'app/views/panel/pages/index.html.erb' copy_file 'install/panel.html.erb', 'app/views/layouts/panel.html.erb' end end end