Skip to content

Commit f3fa6d9

Browse files
committed
Show flash with friendly redirect for exceptioinal Book pages
1 parent 6fcc7a6 commit f3fa6d9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/controllers/books_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def sotechsha2_show; render_book_page(params); end
1414
private
1515

1616
def render_book_page(params)
17-
book_name = params[:action].split('_').first
18-
Book.exist?(book_name, params[:page]) ?
19-
render("books/#{book_name}/#{params[:page]}") :
20-
redirect_to('/' + book_name) # TODO: Show flash
17+
book_title = params[:action].split('_').first
18+
Book.exist?(book_title, params[:page]) ?
19+
render("books/#{book_title}/#{params[:page]}") :
20+
redirect_to("/#{book_title}", flash: { warning: '該当するページが見つかりませんでした 💦'} )
2121
end
2222
end

0 commit comments

Comments
 (0)