Skip to content

Commit

Permalink
Merge pull request #668 from avalonmediasystem/bugfix/api_logging
Browse files Browse the repository at this point in the history
Add logging for when invalid fields are erased
  • Loading branch information
bkeese committed Jan 21, 2016
2 parents eaed38d + 8989df2 commit f4fea6e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/controllers/media_objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ def update_mediaobject
invalid_fields = @mediaobject.errors.keys
required_fields = [:title, :date_issued, :creator]
if !required_fields.any? { |f| invalid_fields.include? f }
#NOTE this will erase all values for fields with multiple values
invalid_fields.each { |field| @mediaobject[field] = nil }
invalid_fields.each do |field|
#NOTE this will erase all values for fields with multiple values
logger.warn "Erasing field #{field} with bad value, bibID: #{Array(params[:fields][:bibliographic_id]).first}, avalon ID: #{@mediaobject.pid}"
@mediaobject[field] = nil
end
end
end
if !@mediaobject.save
Expand Down

0 comments on commit f4fea6e

Please sign in to comment.