Keep getting error that the hash didn't get updated


Hi everyone,
The console keeps telling me that I didn't add to the movies hash but after going back to the example at the beginning I don't see what I'm doing wrong, maybe in the structure (indentation of the various elements) of the case ? However I also tried modifying that in diverse ways and nothing solved it grrrr !!!
I checkout out other user threads about similar issues but since we all do it a little differently I don't seem to see where my version doesn't work.

Thanks for your help !
Here's my code at the moment.

movies = {
    bad_boys: 10

case movies
when "add"
puts "Movie title plz?"
title = gets.chomp
puts "Rating plz?"
rating = gets.chomp
puts movies[title]
when "update" 
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
puts "Error!"


you need to convert the title to all lowercase leters using the .downcase! Ruby method,

title = gets.chomp.downcase! :slight_smile: As well as for choice.


Hi !

Thanks for your reply, I tried adding ".downcase!" but it didn't change anything, also I don't have choice yet cause I'm at the beginning of building the project.


The link that you gave was for lesson 4 of A night at the movies so I assumed you already had it

Please provide me with the correct link to your exercise :slight_smile:


Hi bandit ! Indeed it's that chapter !


If there are no upper case letters in the input, .downcase! returns nil, which is what is happening above. Use .downcase instead so the inputs don't matter.


Ah good to know thanks !
However the hash is still not getting updated this is really scratching my head haha !


rating is a number, so has no .downcase method. Not sure it is getting set.


Changed it, still stuck :frowning:
Could it be the "code layout" of the case block (don't remember if you can call this a block) ?


There should be a command input to start with.

puts "Enter a command: "
command = gets.chomp
case command

Then at that prompt, enter 'add'.


I'm in the Redux part of the course, check my screenshot just above. I think we are unfortunately not on the same wave length regarding this problem, I have to do what you kindly suggested but in the 1st when "add" part of the case.


Why did you write, case movies?

Suggest go back one lesson and review the setup for case.


Maaaan ! I really need to go to bed lol ! Thanks a lot !
Indeed case movies was totally messed up, helped me also find other stuff that wasn't right.
However, in the screen below is my new code now thanks to your help, but for example by going forward from the past exercice with the choice variable, I kept pressing enter hoping to get the "add" option, noob mistake !
Indeed when I wrote add instead of a movie title to display, then I could start with the case's inputs and finish.

A little suggestion to make it more clear for future students would be to add an extra step in the assignment to change the puts that gets the choice variable so that students change it to something like "what option do you want to select?", with then add etc in a string.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.