Sha256: 52fdf628b49c1fa8da109ef7621f0b75074b702a1eb817fcdba268fc47433d96
Contents?: true
Size: 850 Bytes
Versions: 5
Compression:
Stored size: 850 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}, FileUploader """ end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems