Sha256: bd44c0eac29f215bbe2677f994ee38f1bbc5cc6047264aade39377c4269a2421
Contents?: true
Size: 851 Bytes
Versions: 3
Compression:
Stored size: 851 Bytes
Contents
require 'rails' require 'rails/generators/active_record' module Coalla module Cms module FileUploads class MountGenerator < ActiveRecord::Generators::Base argument :name, type: :string argument :field_name, type: :string source_root File.expand_path('../templates', __FILE__) def setup_names @model_name = name.camelize @field_name = field_name end def copy_files migration_template 'add_column_migration.rb.erb', "db/migrate/add_#{@field_name}_field_to_#{@model_name.constantize.table_name}.rb" end def mount_uploader inject_into_class "app/models/#{@model_name.underscore}.rb", @model_name.constantize do " mount_uploader :#{@field_name}, Coalla::FileUploader " end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems