Module: Paperclip::Dimension::ClassMethods
- Defined in:
- lib/paperclip-dimension.rb
Instance Method Summary collapse
-
#has_attached_file(name, options = {}) ⇒ Object
override has_attached_file to: 1).
Instance Method Details
#has_attached_file(name, options = {}) ⇒ Object
override has_attached_file to: 1). save dimensions on post process 2). create dimension accessors
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/paperclip-dimension.rb', line 13 def has_attached_file name, ={} super class_eval <<-END # for ActiveRecord serialize :#{name}_dimensions, Hash if respond_to?(:serialize) def #{name}_dimension(style=:original) self.#{name}_dimensions[style.to_s] end def #{name}_dimension_str(style=:original) dim = #{name}_dimension(style.to_s) dim ? dim.join('x') : nil end END send "after_#{name}_post_process", lambda { save_dimensions_for(name) } end |