ぼざクリ タグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
586 B

  1. class WikiPagesController < ApplicationController
  2. def show
  3. p params
  4. wiki_page = WikiPage.find_by(title: params[:title])
  5. if wiki_page
  6. render plain: wiki_page.markdown
  7. else
  8. head :not_found
  9. end
  10. end
  11. def update
  12. return head :unauthorized unless current_user
  13. title = params[:title]
  14. wiki_page = WikiPage.find_by(title: title)
  15. unless wiki_page
  16. wiki_page = WikiPage.new(title: title, created_user: current_user, updated_user: current_user)
  17. end
  18. wiki_page.markdown = params[:markdown]
  19. wiki_page.save!
  20. head :ok
  21. end
  22. end