This commit is contained in:
2025-06-15 14:24:41 +09:00
parent 50a9313525
commit fe8739b290
8 changed files with 144 additions and 11 deletions
@@ -1,15 +1,16 @@
class WikiPagesController < ApplicationController
def show
wiki_page = WikiPage.find(params[:id])
render json: wiki_page.as_json
return head :not_found unless wiki_page
render json: wiki_page.as_json.merge(body: wiki_page.body)
end
def show_by_title
wiki_page = WikiPage.find_by(title: params[:title])
body = wiki_page&.body
return head :not_found unless body
return head :not_found unless wiki_page
render plain: body
render json: wiki_page.as_json.merge(body: wiki_page.body)
end
def create
@@ -29,7 +30,7 @@ class WikiPagesController < ApplicationController
return head :unauthorized unless current_user
wiki_page = WikiPage.find(params[:id])
return head :not_found unless wiki_pages
return head :not_found unless wiki_page
wiki_page.updated_user = current_user
wiki_page.set_body params[:body], user: current_user