Class: BackendScaffoldGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::ResourceHelpers
Defined in:
lib/generators/backend_scaffold/backend_scaffold_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_controllerObject


13
14
15
# File 'lib/generators/backend_scaffold/backend_scaffold_generator.rb', line 13

def create_controller
  template('controller.rb', File.join('app', 'controllers', 'backend', "#{controller_file_name}_controller.rb"))
end

#create_controller_testObject


31
32
33
# File 'lib/generators/backend_scaffold/backend_scaffold_generator.rb', line 31

def create_controller_test
  template('controller_test.rb', File.join('test', 'controllers', 'backend', "#{table_name}_controller_test.rb"))
end

#create_fixturesObject


23
24
25
# File 'lib/generators/backend_scaffold/backend_scaffold_generator.rb', line 23

def create_fixtures
  template('fixtures.yml', File.join('test', 'fixtures', "#{table_name}.yml"))
end

#create_modelObject


9
10
11
# File 'lib/generators/backend_scaffold/backend_scaffold_generator.rb', line 9

def create_model
  template('model.rb', File.join('app', 'models', "#{singular_table_name}.rb"))
end

#create_model_testObject


27
28
29
# File 'lib/generators/backend_scaffold/backend_scaffold_generator.rb', line 27

def create_model_test
  template('model_test.rb', File.join('test', 'models', "#{singular_table_name}_test.rb"))
end

#create_routeObject


5
6
7
# File 'lib/generators/backend_scaffold/backend_scaffold_generator.rb', line 5

def create_route
  route("resources :#{plural_name}, concerns: [:list, :unroll]")
end

#create_viewsObject


17
18
19
20
21
# File 'lib/generators/backend_scaffold/backend_scaffold_generator.rb', line 17

def create_views
  template('index.html.haml', File.join('app', 'views', 'backend', controller_file_name, 'index.html.haml'))
  template('show.html.haml',  File.join('app', 'views', 'backend', controller_file_name, 'show.html.haml'))
  template('_form.html.haml', File.join('app', 'views', 'backend', controller_file_name, '_form.html.haml'))
end