Sha256: 8c5f69cc8a46f873f6a5fc0c71f87dd59310c60c941244fe8da62ed0f606d5bf
Contents?: true
Size: 1.11 KB
Versions: 19
Compression:
Stored size: 1.11 KB
Contents
# rails generate effective:model NAME [field[:type] field[:type]] [options] # Generates a model # rails generate effective:model Thing # rails generate effective:model Thing name:string description:text module Effective module Generators class ModelGenerator < Rails::Generators::NamedBase include Helpers source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__) desc 'Creates a model in your app/models folder.' argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]' def invoke_model say_status :invoke, :model, :white end def create_model template "#{scaffold_path}/models/model.rb", resource.model_file end protected def parent_class_name options[:parent] || 'ApplicationRecord' end def to_s_attribute [:display_name, :name, :title, :subject].find { |att| invoked_attributes.key?(att) } end def max_attribute_name_length @max_attribute_name_length ||= (invoked_attributes.keys.map { |att| att.to_s.length }.max || 0) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems