Sha256: 6d5b23a350360e869dc4a579024ca1bf611a02a9515d5aeadbb151f4bdd7115f

Contents?: true

Size: 825 Bytes

Versions: 42

Compression:

Stored size: 825 Bytes

Contents

require 'rails/generators/active_record'

class PaperclipGenerator < ActiveRecord::Generators::Base
  desc "Create a migration to add paperclip-specific fields to your model."

  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_migration.rb.erb", "db/migrate/#{migration_file_name}"
  end

  protected

  def migration_name
    "add_attachment_#{attachment_names.join("_")}_to_#{name.underscore}"
  end

  def migration_file_name
    "#{migration_name}.rb"
  end

  def migration_class_name
    migration_name.camelize
  end

end

Version data entries

42 entries across 42 versions & 18 rubygems

Version Path
smarter_paperclip-0.3.0 lib/generators/paperclip/paperclip_generator.rb
cemeng-paperclip-2.3.6 lib/generators/paperclip/paperclip_generator.rb
olek-paperclip-2.3.3.2 lib/generators/paperclip/paperclip_generator.rb
paperclip-2.3.12 lib/generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.10.1 lib/generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.8.6 lib/generators/paperclip/paperclip_generator.rb
sayso-paperclip-2.3.10.001 lib/generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.8.5 lib/generators/paperclip/paperclip_generator.rb
ryansch-paperclip-2.3.10 lib/generators/paperclip/paperclip_generator.rb
olek-paperclip-2.3.3.1 lib/generators/paperclip/paperclip_generator.rb
paperclip-2.3.11 lib/generators/paperclip/paperclip_generator.rb
paperclip-2.3.10 lib/generators/paperclip/paperclip_generator.rb
paperclip-2.3.9 lib/generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.8.4 lib/generators/paperclip/paperclip_generator.rb
paperclip-youtube-2.3.8.2 lib/generators/paperclip/paperclip_generator.rb
paperclip-youtube-2.3.8.1 lib/generators/paperclip/paperclip_generator.rb
radiant-paperclipped-extension-0.8.1 vendor/plugins/paperclip/lib/generators/paperclip/paperclip_generator.rb
paperclip-cloudfiles-2.3.8.3 lib/generators/paperclip/paperclip_generator.rb
whitby3001-paperclip-cloudfiles-2.3.8.1 lib/generators/paperclip/paperclip_generator.rb
organicinternet-paperclip-2.3.8.1 lib/generators/paperclip/paperclip_generator.rb