Sha256: 756979615ec9378c29b418f72f6038f54b1738f93500d2cac2eb8ea30a47de47

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

require 'rails/generators/rails/controller/controller_generator'

module Wanko
  module Generators
    class ControllerGenerator < ::Rails::Generators::ControllerGenerator
      source_root ::Rails::Generators::ControllerGenerator.source_root

      class << self
        def source_paths
          [File.expand_path('../templates', __FILE__), *super]
        end
      end

      # override
      def create_controller_files
        @destination_stack[@destination_stack.size - 1] = File.join @destination_stack.last, 'app/extensions', class_path
        template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
      end

      # override
      private
      def generate_routing_code(action)
        "get '#{file_name}/#{action}'"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wanko-0.0.1 lib/generators/wanko/controller_generator.rb