Class: Godmin::ResourceGenerator

Inherits:
Generators::NamedBase show all
Defined in:
lib/generators/godmin/resource/resource_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

source_paths

Instance Method Details

#add_navigationObject



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

def add_navigation
  append_to_file File.join("app/views", namespaced_path, "shared/_navigation.html.erb") do
    <<-END.strip_heredoc
      <%= navbar_item #{class_name} %>
    END
  end
end

#add_routeObject



6
7
8
# File 'lib/generators/godmin/resource/resource_generator.rb', line 6

def add_route
  route "resources :#{file_name.pluralize}"
end

#create_controllerObject



18
19
20
# File 'lib/generators/godmin/resource/resource_generator.rb', line 18

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

#create_serviceObject



22
23
24
# File 'lib/generators/godmin/resource/resource_generator.rb', line 22

def create_service
  template "resource_service.rb", File.join("app/services", class_path, "#{file_name}_service.rb")
end