Code Won't Pass - Rating Comparison Question


#1

My code passed, but didn't accurately reflect whether the movie was part of the log or not. I thought it made sense to require a rating within my scale (1-5), and so added that as a section of code. I'm not sure what I've done wrong; now, neither part works. Previously added movies are not stopped, and the rating comparison does not register. Can anyone help me figure this out?

movies = { "Casablanca" => 5,
"Harold and Maude" => 5,
"Stepbrothers" => 2,
"A Goofy Movie" => 3,
"Indiana Jones" => 4,
"The Bourne Identity" => 4
}

puts "What is your favorite movie?"
answer = gets.chomp

puts "What would you like to do now?"

choice = gets.chomp.downcase
case choice
when 'add'
puts "What movie would you like to add?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "On a scale of 1-5, how would you rate it?"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
if 1 <= rating <= 5
puts "Great, we've added that movie to the list!"
else
puts "Sorry, the rating needs to be between 1 and 5!"
end
else
puts "That movie already exists! Its rating is #{movies[title.to_sym]}!"
end
when 'update'
puts "Updated!"
when 'display'
puts "Movies!"
when 'delete'
puts "Deleted!"
else
puts "Error!"
end