Sha256: 1f6fbdaae1867629e0b80dd1ab82addda72375bc619693b4547bb9031236cdfe
Contents?: true
Size: 605 Bytes
Versions: 89
Compression:
Stored size: 605 Bytes
Contents
module Acfs::Model # # module Validation def valid?(*args) super remote_errors.each { |f, e| errors.add f, e } errors.empty? end def remote_errors @remote_errors ||= ActiveModel::Errors.new self end def remote_errors=(errors) (errors || []).each do |field, errors| self.errors.set field.to_sym, errors self.remote_errors.set field.to_sym, errors end end def save!(*_) raise ::Acfs::InvalidResource.new resource: self, errors: errors.to_a unless valid? (new? ? :create : :save) super end end end
Version data entries
89 entries across 89 versions & 1 rubygems