Sha256: 25a7b5d87ebea5d8d8223c353bd9e0d92b182e65bb442c797f6127773becf59d
Contents?: true
Size: 996 Bytes
Versions: 10
Compression:
Stored size: 996 Bytes
Contents
require 'rails/generators/active_record' class PaperclipDatabaseGenerator < ActiveRecord::Generators::Base desc "Create a migration to add database storage for the paperclip database storage." + "The NAME argument is the name of your model, and the following " + "arguments are the name of the attachments" argument :attachment_names, :required => true, :type => :array, :desc => "The names of the attachment(s) to add.", :banner => "attachment_one attachment_two attachment_three ..." def self.source_root @source_root ||= File.expand_path('../templates', __FILE__) end def generate_migration migration_template "paperclip_database_migration.rb.erb", "db/migrate/#{migration_file_name}" end protected def migration_name "create_#{name.underscore}_#{attachment_names.map{|n| n.pluralize}.join('_and_')}" end def migration_file_name "#{migration_name}.rb" end def migration_class_name migration_name.camelize end end
Version data entries
10 entries across 10 versions & 1 rubygems