Class: Cmsimple::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Cmsimple::InstallGenerator
- Defined in:
- lib/generators/cmsimple/install/install_generator.rb
Instance Method Summary collapse
- #add_routes ⇒ Object
- #add_to_seeds_file ⇒ Object
- #create_default_template ⇒ Object
- #create_initializer ⇒ Object
- #create_snippets_list ⇒ Object
- #install_migrations ⇒ Object
Instance Method Details
#add_routes ⇒ Object
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_file ⇒ Object
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_template ⇒ Object
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_initializer ⇒ Object
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_list ⇒ Object
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_migrations ⇒ Object
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 |