Class: Overlook::AdminGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/overlook/admin/admin_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_navigationObject



12
13
14
15
16
# File 'lib/generators/overlook/admin/admin_generator.rb', line 12

def add_navigation
  inject_into_file 'app/views/layouts/admin.html.erb', "\n            <%= nav(:#{table_name}) %>", {
    after: /<ul class="nav">/
  }
end

#add_routeObject



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_fileObject



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_filesObject



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