app/models/doc.rb
# transfer doc to repository, if slug exist, auto rename
transfer doc to repository, if slug exist, auto rename
transfer doc to repository if slug exist auto rename
def transfer_to(repo)
    transaction do
      self.repository_id = repo.id
      save!(validate: false)
      toc.update(doc_id: nil)
      toc.destroy
      reload.ensure_toc!
    end
  rescue ActiveRecord::RecordNotUnique
    self.slug = BlueDoc::Slug.random
    retry
  end
def transfer_to ( repo ) transaction do self . repository_id = repo . id save! ( validate : false ) toc . update ( doc_id : nil ) toc . destroy reload . ensure_toc! end rescue ActiveRecord :: RecordNotUnique self . slug = BlueDoc :: Slug . random retry end
transfer doc to repository, if slug exist, auto rename
transfer doc to repository if slug exist auto rename
# free doc releative # destroy to invoke rebuild tree
repo
<not_specific>