From 57bc2cfac8659dd6d7178c4e452b8d453e7afc97 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Wed, 13 Sep 2023 04:56:23 -0500 Subject: [PATCH] Prevent duplicates. Refreshing the page successfully gives a different result every time. --- app/controllers/movies_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 2fe6295..4845584 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,8 +1,8 @@ class MoviesController < ApplicationController def index - @movies = ["Iron Man", "Batman", "Forrest Gump"] + @choices, @movies = ["Iron Man", "Batman", "Forrest Gump"], [] (0..15).each{ |num| - @movies.append(@movies.sample()) + @movies.append(@choices.sample()) } end end