Skip to content

Commit 2727452

Browse files
committed
該当番組が見つからなかった場合は flash メッセージを表示した
1 parent db20520 commit 2727452

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/controllers/podcasts_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def index
1919

2020
def show
2121
@episode = Podcast.find_by(id: params[:id])
22-
redirect_to root_url unless @episode.exists?
22+
if @episode.nil?
23+
flash[:warning] = '該当する番組が見つかりませんでした 💦'
24+
return redirect_to podcasts_path
25+
end
2326

2427
@title = @episode.title.split('-').last.strip
2528
@date = @episode.published_date.strftime("%Y年%-m月%-d日(#{Podcast::WDAY2JAPANESE[@episode.published_date.wday]})")

0 commit comments

Comments
 (0)