Sha256: e1cfc1e39e882a67fd9d2c8c85594eef5da8b637a44f7cb71f348f6405e4abd8

Contents?: true

Size: 1.06 KB

Versions: 18

Compression:

Stored size: 1.06 KB

Contents

require 'rails/generators'

module Edgarj
  class ScaffoldGenerator < Rails::Generators::NamedBase
    include Rails::Generators::ResourceHelpers

    source_root File.expand_path('../templates', __FILE__)
    invoke :model, in: :rails

    def add_edgarj_routes
      route "edgarj_resources :#{file_name.pluralize}"
    end

    def create_controller_files
      template 'controller.rb', File.join('app/controllers',
          class_path, "#{controller_file_name}_controller.rb")
    end

    hook_for :test_framework, as: :scaffold
    hook_for :helper, in: :rails, as: :scaffold do |invoked|
      invoke invoked, [ controller_name ]
    end

=begin
  private
    # copied from TestUnit::Generators::ScaffoldGenerator
    def attributes_hash
      return if attributes_names.empty?

      attributes_names.map do |name|
        if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
          "#{name}: 'secret'"
        else
          "#{name}: @#{singular_table_name}.#{name}"
        end
      end.sort.join(', ')
    end
=end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
edgarj-0.02.00 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.30 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.29 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.28 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.27 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.26 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.25 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.24 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.22 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.21 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.20 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.19 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.18 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.17 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.16 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.15 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.13 lib/generators/edgarj/scaffold/scaffold_generator.rb
edgarj-0.01.12 lib/generators/edgarj/scaffold/scaffold_generator.rb