Sha256: 3c5f2688e0b4f033d30a523bbfb7548db86fe55ea2dc28ad0679f009d57a161f

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 KB

Contents

module Fume

  class SimpleScaffoldGenerator < Rails::Generators::NamedBase
    include Rails::Generators::ResourceHelpers
    source_root File.expand_path('../templates', __FILE__)
    
    argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
    
    def create_controller_files
      template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
    end
    
    def copy_view_files
      %w(index new _form edit).each do |view|
        filename = "#{view}.html.erb"
        template filename, File.join("app/views", controller_file_path, filename)
      end
    end
    
    protected
    # model
    def plural_model_name
      singular_model_name.pluralize
    end
    
    def singular_model_name
      model_class_name.underscore
    end
    
    def model_class_name
      @model_class_name ||= file_name.camelize
    end
    
    # path
    def resources_path_prefix
      (class_path + [plural_model_name]).join('_')
    end

    def resource_path_prefix
      (class_path + [singular_model_name]).join('_')
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fume-0.10.0a lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.9.3 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.9.2 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.9.1 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.9.0 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.8.1a lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.8.0 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.8.0b lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.8.0a lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.7.2 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.7.1 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.7.0 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.6.7 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.6.6 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb
fume-0.6.4 lib/generators/fume/simple_scaffold/simple_scaffold_generator.rb