Module: Watarase::ImageHandler::Macro
- Defined in:
- lib/watarase/image_handler.rb
Instance Method Summary collapse
Instance Method Details
#acts_as_image_handler ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/watarase/image_handler.rb', line 14 def acts_as_image_handler image_holder = (self.name.underscore << '_' << Watarase.suffix).to_sym self.send(:include, Watarase::ImageHandler::Associate) self.send(:has_one, image_holder, primary_key: self.primary_key, foreign_key: "#{self.name.underscore}_#{self.primary_key}", autosave: true, dependent: :destroy) self.send(:attr_accessor, :remove_image) self.send(:before_save, :update_image_holder) end |