Class: Comfy::Generators::CmsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Comfy::Generators::CmsGenerator
- Includes:
- Rails::Generators::Migration, Thor::Actions
- Defined in:
- lib/generators/comfy/cms/cms_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate_assets ⇒ Object
- #generate_cms_seeds ⇒ Object
- #generate_initializer ⇒ Object
- #generate_migration ⇒ Object
- #generate_railties_order ⇒ Object
- #generate_routing ⇒ Object
- #show_readme ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
63 64 65 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 63 def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#generate_assets ⇒ Object
52 53 54 55 56 57 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 52 def generate_assets copy_file "app/assets/javascripts/comfy/admin/cms/custom.js", "app/assets/javascripts/comfy/admin/cms/custom.js" copy_file "app/assets/stylesheets/comfy/admin/cms/custom.sass", "app/assets/stylesheets/comfy/admin/cms/custom.sass" end |
#generate_cms_seeds ⇒ Object
48 49 50 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 48 def generate_cms_seeds directory "db/cms_seeds", "db/cms_seeds" end |
#generate_initializer ⇒ Object
26 27 28 29 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 26 def generate_initializer copy_file "config/initializers/comfortable_mexican_sofa.rb", "config/initializers/comfortable_mexican_sofa.rb" end |
#generate_migration ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 14 def generate_migration destination = File.("db/migrate/01_create_cms.rb", destination_root) migration_dir = File.dirname(destination) destination = self.class.migration_exists?(migration_dir, "create_cms") if destination puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m" else migration_template "db/migrate/01_create_cms.rb", "db/migrate/create_cms.rb" end end |
#generate_railties_order ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 31 def generate_railties_order application <<~RUBY # Ensuring that ActiveStorage routes are loaded before Comfy's globbing # route. Without this file serving routes are inaccessible. config.railties_order = [ActiveStorage::Engine, :main_app, :all] RUBY end |
#generate_routing ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 39 def generate_routing route_string = <<~RUBY comfy_route :cms_admin, path: "/admin" # Ensure that this route is defined last comfy_route :cms, path: "/" RUBY route route_string end |
#show_readme ⇒ Object
59 60 61 |
# File 'lib/generators/comfy/cms/cms_generator.rb', line 59 def show_readme readme "lib/generators/comfy/cms/README" end |