Class: Buildybuild::CmsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/buildybuild/cms/cms_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_routesObject



28
29
30
# File 'lib/generators/buildybuild/cms/cms_generator.rb', line 28

def add_routes
  insert_into_file "config/routes.rb", generated_routes, before: /^end\n*$/
end

#generate_controllerObject



17
18
19
# File 'lib/generators/buildybuild/cms/cms_generator.rb', line 17

def generate_controller
  template("cms_controller.rb", "app/controllers/#{file_names}_controller.rb")
end

#generate_migrationObject



12
13
14
15
# File 'lib/generators/buildybuild/cms/cms_generator.rb', line 12

def generate_migration
  time_stamp = Time.now.strftime('%Y%m%d%I%M%S')
  template("cms_migration.rb", "db/migrate/#{time_stamp}_create_#{file_names}.rb")
end

#generate_modelObject



8
9
10
# File 'lib/generators/buildybuild/cms/cms_generator.rb', line 8

def generate_model
  template("cms_model.rb", "app/models/#{file_name}.rb")
end

#generate_viewsObject



21
22
23
24
25
26
# File 'lib/generators/buildybuild/cms/cms_generator.rb', line 21

def generate_views
  template("cms_new_view.html.haml", "app/views/#{file_names}/new.html.haml")
  template("cms_edit_view.html.haml", "app/views/#{file_names}/edit.html.haml")
  template("cms_show_view.html.haml", "app/views/#{file_names}/show.html.haml")
  template("cms_form_partial.html.haml", "app/views/#{file_names}/_form.html.haml")
end