app/models/collection_item.rb
# Set associated works to anonymous or unrevealed as appropriate
# Check for chapters to avoid work association creation order shenanigans
Set associated works to anonymous or unrevealed as appropriate
Check for chapters to avoid work association creation order shenanigans
Set associated works to anonymous or unrevealed as appropriate Check for chapters to avoid work association creation order shenanigans
def update_work
    return unless item_type == 'Work' && work.present? && work.chapters.present? && !work.new_record?
    if self.id_changed?
      work.set_anon_unrevealed!
    else
      work.update_anon_unrevealed!
    end
  end
def update_work return unless item_type == 'Work' && work . present? && work . chapters . present? && ! work . new_record? if self . id_changed? work . set_anon_unrevealed! else work . update_anon_unrevealed! end end
Set associated works to anonymous or unrevealed as appropriate
Check for chapters to avoid work association creation order shenanigans
Set associated works to anonymous or unrevealed as appropriate Check for chapters to avoid work association creation order shenanigans
# Check if this is new - can't use new_record? with after_save