Sha256: 458eef5c8dcc9dc5af3be6bd32186a9e92c0b53b959b10e0200cab95a3dff645

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'

class SelectionsScaffoldGenerator < Rails::Generators::Base
  include Rails::Generators::Migration

  source_root File.expand_path('../templates', __FILE__)

  def self.next_migration_number(path)
    ActiveRecord::Generators::Base.next_migration_number(path)
  end

  def generate_selections_scaffold
    {
        'selection_spec.rb' => 'spec/models/',
        'selection.rb' => 'app/models/',
        'selections_controller_spec.rb' => 'spec/controllers/',
        'selections_controller.rb' => 'app/controllers/',
        'selections_helper.rb' => 'app/helpers/',
        'selections.yml' => 'spec/fixtures/',
        '_form.html.haml' => 'app/views/selections/',
        'edit.html.haml' => 'app/views/selections/',
        'index.html.haml' => 'app/views/selections/',
        'new.html.haml' => 'app/views/selections/'
    }.each_pair do |file, dir|
      copy_file file, dir + file
    end

    migration_template 'create_selections.rb', 'db/migrate/create_selections.rb'

    route 'resources(:selections, only: :index) { resources :selections, except: :show }'

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selections-0.2.2 lib/generators/selections_scaffold/selections_scaffold_generator.rb