modify controller/document_controller.rb and model/document.rb