Skip to content

Commit

Permalink
該当番組が見つからなかった場合は flash メッセージを表示した
Browse files Browse the repository at this point in the history
  • Loading branch information
yasulab committed Apr 10, 2024
1 parent db20520 commit 2727452
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/podcasts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def index

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

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

0 comments on commit 2727452

Please sign in to comment.