Class: ActiveAdmin::Cms::PageGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- ActiveAdmin::Cms::PageGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/active_admin/cms/page/page_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_admin ⇒ Object
- #create_admin_views ⇒ Object
- #create_migrations ⇒ Object
- #create_model ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
8 9 10 |
# File 'lib/generators/active_admin/cms/page/page_generator.rb', line 8 def self.next_migration_number(dirname) Time.now.strftime("%Y%m%d%H%M%S") end |
.source_root ⇒ Object
12 13 14 |
# File 'lib/generators/active_admin/cms/page/page_generator.rb', line 12 def self.source_root @_active_admin_cms_source_root ||= File.("../templates", __FILE__) end |
Instance Method Details
#create_admin ⇒ Object
16 17 18 |
# File 'lib/generators/active_admin/cms/page/page_generator.rb', line 16 def create_admin template 'admin/pages.rb.erb', "app/admin/#{plural_table_name}.rb" end |
#create_admin_views ⇒ Object
24 25 26 27 28 29 |
# File 'lib/generators/active_admin/cms/page/page_generator.rb', line 24 def create_admin_views template 'views/admin/cms/pages/_form.html.haml', "app/views/admin/cms/#{plural_table_name}/_form.html.haml" template 'views/admin/cms/pages/_ingredient.html.haml', "app/views/admin/cms/#{plural_table_name}/_ingredient.html.haml" template 'views/admin/cms/pages/_section.html.haml', "app/views/admin/cms/#{plural_table_name}/_section.html.haml" template 'views/admin/cms/pages/_show.html.haml', "app/views/admin/cms/#{plural_table_name}/_show.html.haml" end |
#create_migrations ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/generators/active_admin/cms/page/page_generator.rb', line 31 def create_migrations Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath| name = File.basename(filepath) migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}" sleep 1 end end |
#create_model ⇒ Object
20 21 22 |
# File 'lib/generators/active_admin/cms/page/page_generator.rb', line 20 def create_model template 'page.rb.erb', "app/models/#{file_path}.rb" end |