Sha256: 5416f61160af0973235e27bab9aa32f35f39ae5900f0b9099b30f3e832e057db
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 Bytes
Contents
class PaperclipDatabaseGenerator < Rails::Generator::NamedBase attr_accessor :attachments, :migration_name def initialize(args, options = {}) super @class_name, @attachments = args[0], args[1..-1] end def manifest file_name = generate_file_name @migration_name = file_name.camelize record do |m| m.migration_template "paperclip_database_migration.rb.erb", File.join('db', 'migrate'), :migration_file_name => file_name end end private def generate_file_name debugger names = attachments.map{|a| "#{class_name.underscore.tr('/', '_')}_#{a.pluralize}" } names = names[0..-2] + ["and", names[-1]] if names.length > 1 "create_#{names.join('_')}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paperclip_database-2.2.0 | generators/paperclip_database/paperclip_database_generator.rb |