Safe navigation for serializer value of RepositoryListItem

This commit is contained in:
Urban Rotnik 2020-01-28 13:38:37 +01:00
parent 83f4344bb7
commit 13c9dd8cf6
2 changed files with 3 additions and 3 deletions

View file

@ -11,5 +11,5 @@ class RepositoryChecklistItem < ApplicationRecord
belongs_to :last_modified_by, foreign_key: 'last_modified_by_id', class_name: 'User',
inverse_of: :modified_repository_checklist_types
has_many :repository_checklist_items_values, dependent: :destroy
has_many :repository_checklist_values, through: :repository_checklist_items_values
has_many :repository_checklist_values, through: :repository_checklist_items_values, dependent: :destroy
end

View file

@ -4,8 +4,8 @@ module RepositoryDatatable
class RepositoryListValueSerializer < RepositoryBaseValueSerializer
def value
{
id: object.repository_list_item.id,
text: object.data
id: (object.repository_list_item&.id || ''),
text: (object.data || '')
}
end
end