Class: Cmsimple::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/cmsimple/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_routesObject



12
13
14
15
# File 'lib/generators/cmsimple/install/install_generator.rb', line 12

def add_routes
  route %Q{#this route should always be last
mount Cmsimple::Engine => '/'}
end

#add_to_seeds_fileObject



26
27
28
29
30
31
32
33
34
# File 'lib/generators/cmsimple/install/install_generator.rb', line 26

def add_to_seeds_file
 seed = <<-SEED
unless Cmsimple::Page.where(is_root: true).first
page = Cmsimple::Page.create is_root: true, title: 'Home', template: 'default'
page.publish!
end
 SEED
 append_to_file 'db/seeds.rb', seed
end

#create_default_templateObject



17
18
19
20
# File 'lib/generators/cmsimple/install/install_generator.rb', line 17

def create_default_template
  file = "default.html.#{handler}"
  template file, "app/views/cmsimple/templates/#{file}"
end

#create_initializerObject



8
9
10
# File 'lib/generators/cmsimple/install/install_generator.rb', line 8

def create_initializer
  template 'initializer.rb', 'config/initializers/cmsimple.rb'
end

#create_snippets_listObject



22
23
24
# File 'lib/generators/cmsimple/install/install_generator.rb', line 22

def create_snippets_list
  create_file "app/views/cmsimple/_snippet_list.html.#{handler}", "Run the snippet generator to add a snippet"
end

#install_migrationsObject



36
37
38
39
40
# File 'lib/generators/cmsimple/install/install_generator.rb', line 36

def install_migrations
  rake('cmsimple:install:migrations')
  rake('db:migrate')
  rake('db:seed')
end