Class: Plain::DocsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Plain::DocsController
- Defined in:
- app/controllers/plain/docs_controller.rb
Instance Method Summary collapse
Instance Method Details
#edit ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/plain/docs_controller.rb', line 8 def edit get_docs @action = "edit" @markdown = DocsService.get_markdown(@file_path) @document = Plain::Document.new @document.title = @markdown.front_matter["title"] @document. = @markdown.front_matter["menu_position"] @document.content = @markdown.content @document.path = @file_path end |
#show ⇒ Object
4 5 6 |
# File 'app/controllers/plain/docs_controller.rb', line 4 def show get_docs end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/plain/docs_controller.rb', line 19 def update get_docs @action = "edit" doc_params = params.require(:document).permit(:path, :content, :menu_position, :title) @markdown = DocsService.get_markdown(@file_path) @document = Plain::Document.new @document.title = doc_params["title"] @document. = doc_params["menu_position"] @document.content = doc_params["content"] @document.path = doc_params["path"] @document.current_path = @file_path puts @document.valid? if @document.save redirect_to docs_path(@file_path) else render "edit" end end |