Sha256: c17f4c51e5a47de22b5120b530173a87fc1198940611b3dcf2ee899719e011f3

Contents?: true

Size: 744 Bytes

Versions: 7

Compression:

Stored size: 744 Bytes

Contents

require 'rails/generators/erb'
require 'rails/generators/resource_helpers'

class Rails::HamlModalCrudGenerator < Rails::Generators::NamedBase
  include Rails::Generators::ResourceHelpers
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
  source_root File.expand_path('../templates', __FILE__)

  def copy_view_files
    available_actions.each do |view|
      template "#{view}.js.erb", File.join("app/views", controller_file_path, "#{view}.js.erb")
    end
    run_haml
  end

  protected

  def available_actions
    %w(create update destroy)
  end

  def handler
    :erb
  end

  def run_haml
    attrs = attributes.collect {|a| "#{a.name}:#{a.type}" }
    generate 'haml:scaffold', name, *attrs
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bootbox_crud-0.1.1.6 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.1.1.5 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.1.1.4 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.1.1.3 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.1.1.2 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.1.1.1 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.1.1 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb