Skip to content

Commit

Permalink
Make sure a digital object with no links does not create an empty link
Browse files Browse the repository at this point in the history
  • Loading branch information
xhero committed Dec 5, 2018
1 parent 2980692 commit 5ee6b90
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/admin/digital_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ def create
success.html do
# If we have a new_object_link_type/id, also create the object link - See the DigitalObjectLink for
# the fake accessors and the form below for the hidden fields
if (params[:digital_object][:new_object_link_type] && params[:digital_object][:new_object_link_id])
if (params[:digital_object][:new_object_link_type] && params[:digital_object][:new_object_link_id] &&
!params[:digital_object][:new_object_link_type].empty? && !params[:digital_object][:new_object_link_id].empty?
)
dol = DigitalObjectLink.new(
object_link_type: params[:digital_object][:new_object_link_type],
object_link_id: params[:digital_object][:new_object_link_id],
user: resource.user,
digital_object_id: resource.id
)
digital_object_id: resource.id)
dol.save!
end
redirect_to admin_digital_object_path(resource.id)
Expand Down

0 comments on commit 5ee6b90

Please sign in to comment.