Sha256: ca72c95a3611ef4cb5eea35317ea96475f4b5b17653272cf9425d8dc4cd6f980

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

require 'rails/generators/active_record'

module Coalla
  module Cms

    class CreateMarkupGenerator < ActiveRecord::Generators::Base
      argument :name, type: :string, default: ""
      source_root File.expand_path('../templates', __FILE__)

      def copy_controller_file
        template 'controllers/markup_controller.rb.erb', 'app/controllers/markup_controller.rb'
        empty_directory 'app/views/markup'
      end

      def setup_routes
        sentinel = /namespace :admin do\s*$/

        routing_code = <<EOF
  scope controller: :markup, as: :markup, path: 'markup' do
    get :lot
  end
EOF

        in_root do
          inject_into_file 'config/routes.rb', "\n  #{routing_code}", {after: sentinel}
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coalla-cms-0.5.2.4 lib/generators/coalla/cms/create_markup_generator.rb
coalla-cms-0.5.1.9 lib/generators/coalla/cms/create_markup_generator.rb
coalla-cms-0.5.1.8 lib/generators/coalla/cms/create_markup_generator.rb