Sha256: a241de92468d7a059f315a06ede954c15c91968c313575e8e3046cc624bf0760

Contents?: true

Size: 736 Bytes

Versions: 67

Compression:

Stored size: 736 Bytes

Contents

class PaperclipGenerator < 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_migration.rb.erb",
                           File.join('db', 'migrate'),
                           :migration_file_name => file_name
    end
  end

  private

  def generate_file_name
    names = attachments.map{|a| a.underscore }
    names = names[0..-2] + ["and", names[-1]] if names.length > 1
    "add_attachments_#{names.join("_")}_to_#{@class_name.underscore}"
  end

end

Version data entries

67 entries across 67 versions & 23 rubygems

Version Path
paperclip-youtube-2.3.8.1 generators/paperclip/paperclip_generator.rb
radiant-paperclipped-extension-0.8.1 vendor/plugins/paperclip/generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.8.3 generators/paperclip/paperclip_generator.rb
whitby3001-paperclip-cloudfiles-2.3.8.1 generators/paperclip/paperclip_generator.rb
organicinternet-paperclip-2.3.8.1 generators/paperclip/paperclip_generator.rb
arielvalentin-paperclip-2.3.6 generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.8.1 generators/paperclip/paperclip_generator.rb
twm_paperclip-2.3.8t generators/paperclip/paperclip_generator.rb
reenhanced-paperclip-2.3.8 generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.8 generators/paperclip/paperclip_generator.rb
paperclip-2.3.8 generators/paperclip/paperclip_generator.rb
paperclip-2.3.7 generators/paperclip/paperclip_generator.rb
twm_paperclip-2.3.6b generators/paperclip/paperclip_generator.rb
twm_paperclip-2.3.6 generators/paperclip/paperclip_generator.rb
paperclip-2.3.6 generators/paperclip/paperclip_generator.rb
path-paperclip-2.3.3 generators/paperclip/paperclip_generator.rb
paperclip-2.3.5 generators/paperclip/paperclip_generator.rb
paperclip-2.3.4 generators/paperclip/paperclip_generator.rb
bookis-paperclip-2.3.3.1 generators/paperclip/paperclip_generator.rb
bookis-paperclip-2.3.3 generators/paperclip/paperclip_generator.rb