Sha256: c7351b3da195e2c07dd6a130d9c5e58ecb0d5b8cf7b2c3fed3d35d75fa138e17
Contents?: true
Size: 777 Bytes
Versions: 30
Compression:
Stored size: 777 Bytes
Contents
require 'rails/generators/active_record' module Adminpanel class ContactGenerator < ActiveRecord::Generators::Base desc 'Generate the contact template to use with a mail form' source_root File.expand_path('../templates', __FILE__) argument :name, type: :string, default: '', required: false argument :fields, type: :array, default: [], required: false def copy_contact fields = extract_fields template 'contact_template.rb', 'app/models/contact.rb' end private def extract_fields if fields.empty? && name == '' # no fields supplied fields << 'email' fields << 'body' elsif name != '' # at least 1 field supplied fields << name end return fields end end end
Version data entries
30 entries across 30 versions & 1 rubygems