Sha256: 1c6dbcafd0a5a217ea0ba718455ada5832518b3c6327afe8966a68afe6b17d7c

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'

module ScaffoldController
  class ScaffoldhubGenerator < Rails::Generators::ScaffoldControllerGenerator

    include Scaffoldhub::Helper

    remove_hook_for :template_engine
    hook_for        :template_engine, :as => :scaffoldhub

    remove_hook_for :helper
    # Invoke the helper using the controller name (pluralized)
    hook_for        :helper, :as => :scaffoldhub do |invoked|
      invoke invoked, [ controller_name ]
    end

    class_option :scaffold, :default => 'default', :banner => "SCAFFOLD_NAME",  :type => :string,  :desc => "Scaffold to use"
    class_option :local,    :default => false,     :banner => "LOCAL SCAFFOLD", :type => :boolean, :desc => "Use a local scaffold, not scaffoldhub.org"

    def create_controller_files
      controller_template_file = find_template_file(:controller)
      template controller_template_file.src, File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb") if controller_template_file
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scaffoldhub-0.1.1 lib/generators/scaffold_controller/scaffoldhub_generator.rb