Sha256: 6f2388f23f9bc92f0241679547be3cbcb4dfc0f593686dcf698a97eebb97ca58
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 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 || klass_attributes).map do |attribute| Rails::Generators::GeneratedAttribute.parse(attribute) end self.class.send(:attr_reader, :attributes) end def invoke_views say_status :invoke, :views, :white end def create_views (invoked_actions & available_actions).each do |action| template "views/#{action}.html.haml", File.join('app/views', namespace_path, (namespace_path.present? ? '' : class_path), plural_name, "#{action}.html.haml") end template "views/_resource.html.haml", File.join('app/views', namespace_path, (namespace_path.present? ? '' : class_path), plural_name, "_#{singular_name}.html.haml") end private def available_actions %w(index new show edit) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
effective_developer-0.0.10 | lib/generators/effective/views_generator.rb |
effective_developer-0.0.9 | lib/generators/effective/views_generator.rb |