Class: Overlook::AdminGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Overlook::AdminGenerator
- Defined in:
- lib/generators/overlook/admin/admin_generator.rb
Instance Method Summary collapse
- #add_navigation ⇒ Object
- #add_route ⇒ Object
- #copy_controller_file ⇒ Object
- #copy_view_files ⇒ Object
Instance Method Details
#add_navigation ⇒ Object
12 13 14 15 16 |
# File 'lib/generators/overlook/admin/admin_generator.rb', line 12 def inject_into_file 'app/views/layouts/admin.html.erb', "\n <%= nav(:#{table_name}) %>", { after: /<ul class="nav">/ } end |
#add_route ⇒ Object
6 7 8 9 10 |
# File 'lib/generators/overlook/admin/admin_generator.rb', line 6 def add_route inject_into_file 'config/routes.rb', "\n resources :#{table_name}", { after: /namespace :admin do$/ } end |
#copy_controller_file ⇒ Object
18 19 20 |
# File 'lib/generators/overlook/admin/admin_generator.rb', line 18 def copy_controller_file template "controller.rb", "app/controllers/admin/#{plural_file_name}_controller.rb" end |
#copy_view_files ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/overlook/admin/admin_generator.rb', line 22 def copy_view_files template "index.html.erb", "app/views/admin/#{plural_file_name}/index.html.erb" template "show.html.erb", "app/views/admin/#{plural_file_name}/show.html.erb" template "new.html.erb", "app/views/admin/#{plural_file_name}/new.html.erb" template "edit.html.erb", "app/views/admin/#{plural_file_name}/edit.html.erb" template "form.html.erb", "app/views/admin/#{plural_file_name}/_form.html.erb" template "partial.html.erb", "app/views/admin/#{plural_file_name}/_#{file_name}.html.erb" template "sidebar.html.erb", "app/views/admin/#{plural_file_name}/_sidebar.html.erb" template "breadcrumb.html.erb", "app/views/admin/#{plural_file_name}/_breadcrumb.html.erb" template "destroy.js.erb", "app/views/admin/#{plural_file_name}/destroy.js.erb" end |