Sha256: f5bee7f19bc181f1365f21b666f723547d1eabef8f2694b6d4005a6f1b2059ec
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
# rails generate effective:form NAME [field[:type] field[:type]] [options] # TODO # Generates a form # rails generate effective:form Thing # rails generate effective:form Thing name:string description:text module Effective module Generators class FormGenerator < Rails::Generators::NamedBase include Helpers source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__) desc 'Creates a _form.html.haml in your app/views/model/ folder.' argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]' def assign_attributes @attributes = (invoked_attributes.presence || klass_attributes).map do |attribute| Rails::Generators::GeneratedAttribute.parse(attribute) end end def invoke_form say_status :invoke, :form, :white end def create_form template 'forms/_form.html.haml', File.join('app/views', namespace_path, (namespace_path.present? ? '' : class_path), plural_name, '_form.html.haml') end protected def form_for if namespaces.blank? singular_name else '[' + namespaces.map { |ns| ':' + ns }.join(', ') + ', ' + singular_name + ']' end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
effective_developer-0.0.10 | lib/generators/effective/form_generator.rb |
effective_developer-0.0.9 | lib/generators/effective/form_generator.rb |