In Files

Files

Class/Module Index [+]

Quicksearch

Paperclip

The base module that gets included in ActiveRecord::Base. See the documentation for Paperclip::ClassMethods for more useful information.

Constants

VERSION

Attributes

classes_with_attachments[RW]
registered_attachments_styles_path[W]

Public Class Methods

io_adapters() click to toggle source
# File lib/paperclip.rb, line 91
def self.io_adapters
  @io_adapters ||= Paperclip::AdapterRegistry.new
end
io_adapters=(new_registry) click to toggle source
# File lib/paperclip.rb, line 87
def self.io_adapters=(new_registry)
  @io_adapters = new_registry
end
missing_attachments_styles() click to toggle source

Returns hash with styles missing from recent run of rake paperclip:refresh:missing_styles

{
  :User => {:avatar => [:big]},
  :Book => {
    :cover => [:croppable]},
  }
}
# File lib/paperclip/missing_attachment_styles.rb, line 64
def self.missing_attachments_styles
  current_styles = current_attachments_styles
  registered_styles = get_registered_attachments_styles

  Hash.new.tap do |missing_styles|
    current_styles.each do |klass, attachment_definitions|
      attachment_definitions.each do |attachment_name, styles|
        registered = registered_styles[klass][attachment_name] || [] rescue []
        missed = styles - registered
        if missed.present?
          klass_sym = klass.to_s.to_sym
          missing_styles[klass_sym] ||= Hash.new
          missing_styles[klass_sym][attachment_name.to_sym] ||= Array.new
          missing_styles[klass_sym][attachment_name.to_sym].concat(missed.to_a)
          missing_styles[klass_sym][attachment_name.to_sym].map!(&:to_s).sort!.map!(&:to_sym).uniq!
        end
      end
    end
  end
end
options() click to toggle source

Provides configurability to Paperclip. The options available are:

  • whiny: Will raise an error if Paperclip cannot process thumbnails of an uploaded image. Defaults to true.

  • log: Logs progress to the Rails log. Uses ActiveRecord's logger, so honors log levels, etc. Defaults to true.

  • command_path: Defines the path at which to find the command line programs if they are not visible to Rails the system's search path. Defaults to nil, which uses the first executable found in the user's search path.

# File lib/paperclip.rb, line 76
def self.options
  @options ||= {
    :whiny             => true,
    :image_magick_path => nil,
    :command_path      => nil,
    :log               => true,
    :log_command       => true,
    :swallow_stderr    => true
  }
end
registered_attachments_styles_path() click to toggle source
# File lib/paperclip/missing_attachment_styles.rb, line 7
def registered_attachments_styles_path
  @registered_attachments_styles_path ||= Rails.root.join('public/system/paperclip_attachments.yml').to_s
end
save_current_attachments_styles!() click to toggle source
# File lib/paperclip/missing_attachment_styles.rb, line 22
def self.save_current_attachments_styles!
  File.open(Paperclip.registered_attachments_styles_path, 'w') do |f|
    YAML.dump(current_attachments_styles, f)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.