404
This commit is contained in:
parent
5e9c7fa37e
commit
a2cc0a737e
3 changed files with 24 additions and 1 deletions
|
@ -39,16 +39,19 @@ end
|
|||
|
||||
get '/memos/:id' do
|
||||
@memo = load_memos[params[:id]]
|
||||
halt 404, erb(:not_found) unless @memo
|
||||
erb :show
|
||||
end
|
||||
|
||||
get '/memos/:id/edit' do
|
||||
@memo = load_memos[params[:id]]
|
||||
halt 404, erb(:not_found) unless @memo
|
||||
erb :edit
|
||||
end
|
||||
|
||||
patch '/memos/:id' do
|
||||
memos = load_memos
|
||||
halt 404, erb(:not_found) unless memos[params[:id]]
|
||||
memos[params[:id]] = { 'title' => params[:title], 'content' => params[:content] }
|
||||
save_memos(memos)
|
||||
redirect "/memos/#{params[:id]}"
|
||||
|
@ -56,7 +59,11 @@ end
|
|||
|
||||
delete '/memos/:id' do
|
||||
memos = load_memos
|
||||
memos.delete(params[:id])
|
||||
halt 404, erb(:not_found) unless memos.delete(params[:id])
|
||||
save_memos(memos)
|
||||
redirect '/memos'
|
||||
end
|
||||
|
||||
not_found do
|
||||
erb :not_found
|
||||
end
|
||||
|
|
|
@ -2,5 +2,9 @@
|
|||
"1": {
|
||||
"title": "",
|
||||
"content": ""
|
||||
},
|
||||
"2": {
|
||||
"title": "a",
|
||||
"content": "aaa"
|
||||
}
|
||||
}
|
12
memoapp/views/not_found.erb
Normal file
12
memoapp/views/not_found.erb
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>404 Not Found</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>404 Not Found</h1>
|
||||
<p>お探しのページは見つかりませんでした。</p>
|
||||
<a href="/memos">メモ一覧に戻る</a>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue