Sha256: 154e52e43ed0eb6f2364a3f95be1514d49702f246ecf00162c8a43b50b983c79

Contents?: true

Size: 1.18 KB

Versions: 19

Compression:

Stored size: 1.18 KB

Contents

# rails generate effective:views NAME [action action] [options]

# Generates a view
# rails generate effective:views Thing
# rails generate effective:views Thing index show new
# rails generate effective:views Thing index show --attributes name:string description:text

module Effective
  module Generators
    class ViewsGenerator < Rails::Generators::NamedBase
      include Helpers
      source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)

      desc 'Creates views in your app/views folder.'

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

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

      def invoke_views
        say_status :invoke, :views, :white
      end

      def create_views
        if invoked_actions.include?('show') || non_crud_actions.present?
          template 'views/_resource.html.haml', resource.view_file(resource.name, partial: true)
        end
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
effective_developer-0.5.5 lib/generators/effective/views_generator.rb
effective_developer-0.5.4 lib/generators/effective/views_generator.rb
effective_developer-0.5.3 lib/generators/effective/views_generator.rb
effective_developer-0.5.2 lib/generators/effective/views_generator.rb
effective_developer-0.5.1 lib/generators/effective/views_generator.rb
effective_developer-0.5.0 lib/generators/effective/views_generator.rb
effective_developer-0.4.16 lib/generators/effective/views_generator.rb
effective_developer-0.4.15 lib/generators/effective/views_generator.rb
effective_developer-0.4.14 lib/generators/effective/views_generator.rb
effective_developer-0.4.13 lib/generators/effective/views_generator.rb
effective_developer-0.4.12 lib/generators/effective/views_generator.rb
effective_developer-0.4.11 lib/generators/effective/views_generator.rb
effective_developer-0.4.10 lib/generators/effective/views_generator.rb
effective_developer-0.4.9 lib/generators/effective/views_generator.rb
effective_developer-0.4.8 lib/generators/effective/views_generator.rb
effective_developer-0.4.7 lib/generators/effective/views_generator.rb
effective_developer-0.4.6 lib/generators/effective/views_generator.rb
effective_developer-0.4.5 lib/generators/effective/views_generator.rb
effective_developer-0.4.4 lib/generators/effective/views_generator.rb