Learn your paperclip

首先、查看paperclip.rb就能看到它由一个很重要的方法,也就是 has_attached_file(name, options = {}) 啦!

接下来、从目录结构上就可以看出由 generate / rake / paperclip 三者构成。
并且 generate / rake 都只有一个文件,并不复杂,很容易理解。

再下来、它有:
validates_attachment(*attributes) 校验
测试例子 matchers.rb

对于我们上传的‘文件‘,有如下 * Attacthment *

   def self.default_options
      @default_options ||= {
        :convert_options => {},
        :default_style => :original,
        :default_url => "/:attachment/:style/missing.png",
        :restricted_characters => /[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/,
        :hash_data => ":class/:attachment/:id/:style/:updated_at",
        :hash_digest => "SHA1",
        :interpolator => Paperclip::Interpolations,
        :only_process => [],
        :path => ":rails_root/public:url",
        :preserve_files => false,
        :processors => [:thumbnail],
        :source_file_options => {},
        :storage => :filesystem,
        :styles => {},
        :url => "/system/:class/:attachment/:id_partition/:style/:filename",
        :url_generator => Paperclip::UrlGenerator,
        :use_default_time_zone => true,
        :use_timestamp => true,
        :whiny => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails]
      }
    end

还有一些其它的,可以通过查看 README 了解。

https://github.com/thoughtbot/paperclip

你可能感兴趣的:(Learn your paperclip)