Skip to content

Commit

Permalink
Reload @meal_post before rendering new edition partial
Browse files Browse the repository at this point in the history
  • Loading branch information
kudojp committed May 17, 2020
1 parent d30644f commit 0942aa5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/meal_posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def update
end
end

# @meal_post.food_itemsのそれぞれのmark_for_destructionをfalseに戻すため
# ここで設定しないと以下のようなバグが生じる
# (例)food_itemsを全て消して投稿した後に、画面描写後再び投稿ボタンを押すと「Food items should have at least 1 food item.」をいうエラーが出る
@meal_post.reload

respond_to do |format|
# TODO: friendly forwardingを実装
# TODO: errorを伝搬するなりして、alertをもう少しdescriptiveにする
Expand Down

0 comments on commit 0942aa5

Please sign in to comment.