app/controllers/list_items_controller.rb
# Add existing dish to current user's list
Add existing dish to current user's list
Add existing dish to current user ' s list
def create
    list_item = @list.list_items.build(dish_id: params[:dish_id])
    if list_item.save
      increase_dish_popularity(list_item.dish)
      redirect_to user_dishes_path(current_user), alert: "Dish successfully added to your list"
    else
      redirect_to user_dishes_path(current_user), alert: "Unable to add dish to list"
    end
  end
def create list_item = @list . list_items . build ( dish_id : params [ :dish_id ] ) if list_item . save increase_dish_popularity ( list_item . dish ) redirect_to user_dishes_path ( current_user ) , alert : "Dish successfully added to your list" else redirect_to user_dishes_path ( current_user ) , alert : "Unable to add dish to list" end end
Add existing dish to current user's list
Add existing dish to current user ' s list