Sha256: a0e4038439edeca3bbef626a32fdd95c20311ad1333ecbdef7b0f7bd9859d139
Contents?: true
Size: 715 Bytes
Versions: 277
Compression:
Stored size: 715 Bytes
Contents
module ForestLiana class BelongsToUpdater attr_accessor :errors def initialize(resource, association, params) @resource = resource @association = association @params = params @data = params['data'] @errors = nil end def perform begin @record = @resource.find(@params[:id]) new_value = @association.klass.find(@data[:id]) if @data && @data[:id] @record.send("#{@association.name}=", new_value) @record.save rescue ActiveRecord::SerializationTypeMismatch => exception @errors = [{ detail: exception.message }] rescue => exception @errors = [{ detail: exception.message }] end end end end
Version data entries
277 entries across 277 versions & 1 rubygems