Sha256: 04fdabfcc5d168060e54ee9b4a846eb021f560b151dfc7965ce0ccd4370f524d

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# rails generate effective:datatable NAME [field[:type] field[:type]] [options]

# TODO

# Generates a datatable
# rails generate effective:datatable Thing
# rails generate effective:controller Thing name:string description:text

module Effective
  module Generators
    class DatatableGenerator < Rails::Generators::NamedBase
      include Helpers

      source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)

      desc 'Creates an Effective::Datatable in your app/datatables folder.'

      argument :actions, type: :array, default: ['crud'], banner: 'action action'
      class_option :attributes, type: :array, default: [], desc: 'Included permitted params, otherwise read from model'

      def assign_attributes
        @attributes = invoked_attributes.presence || resource_attributes
        self.class.send(:attr_reader, :attributes)
      end

      def invoke_datatable
        say_status :invoke, :datatable, :white
      end

      def create_datatable
        template 'datatables/datatable.rb', resource.datatable_file
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
effective_developer-0.2.2 lib/generators/effective/datatable_generator.rb
effective_developer-0.2.1 lib/generators/effective/datatable_generator.rb
effective_developer-0.2 lib/generators/effective/datatable_generator.rb
effective_developer-0.1.1 lib/generators/effective/datatable_generator.rb