module Mongoid::Refile
Public Class Methods
attachment(name, raise_errors: false, **_options)
click to toggle source
Calls superclass method
# File lib/mongoid/refile.rb, line 11 def self.attachment(name, raise_errors: false, **_options) super attacher = "#{name}_attacher" field "#{name}_id".to_sym, type: String before_save do send(attacher).store! end after_destroy do send(attacher).delete! end before_validation do if send(attacher).present? send(attacher).valid? send(attacher).errors.each do |error| errors.add(name, error) end end end end