Class: AlterAdmin::Generators::ResourceGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/alter_admin/resource/resource_generator.rb

Instance Method Summary collapse

Methods inherited from Base

source_root

Instance Method Details

#add_model_admin_settingObject



25
26
27
# File 'lib/generators/alter_admin/resource/resource_generator.rb', line 25

def add_model_admin_setting
  template "t_model_setting.rb", File.join('app/admin', "#{file_name}_admin_setting.rb")
end

#add_routeObject



11
12
13
14
15
16
17
# File 'lib/generators/alter_admin/resource/resource_generator.rb', line 11

def add_route
  route <<-ROUTE
    namespace :admin do
      resources :#{plural_name}
    end
  ROUTE
end

#add_viewsObject



19
20
21
22
23
# File 'lib/generators/alter_admin/resource/resource_generator.rb', line 19

def add_views
  %w{index edit new _form show}.each do |view|
    template "views/#{view}.html.slim", File.join('app/views/admin', "#{file_name.pluralize}/#{view}.html.slim")
  end
end

#create_controllerObject



7
8
9
# File 'lib/generators/alter_admin/resource/resource_generator.rb', line 7

def create_controller
  template "controller.rb", File.join('app/controllers/admin', "#{file_name.pluralize}_controller.rb")
end