"you didn't add Grease to the movies hash!"


#1



https://www.codecademy.com/en/courses/ruby-beginner-en-0i8v1/0/4?curriculum_id=5059f8619189a5000201fbcb#

ERROR
"you didn't add Grease to the movies hash!"
I can see that tons of people have this problem, but I have been working on it now for close to 3 hours! (embarrassing, I know). I have read others questions and answers, but it's just not working.


movies = {
    American_Hustle: 10,
}

puts "What movie title do you want to add?"
title = gets.chomp
case title 
	
when "add"
	puts "Add a movie title."
	title = gets.chomp
	puts "How do you rate this movie?"
	rating = gets.chomp
movies[title] = "rating" 	
	puts "#{title} has been added"
when "display"
	puts "Movies!"
when "delete"
	puts "Deleted!"
else puts "Error!"
end


#2

Hello @marcidenmark,

if you notice closely, in your first when clause of your case statement, when you ask the user what movie title they want to add, you create a new Hash entry with the movie name, but the rating isn't quite accurate. You have set the new Hash entry to a rating of the string "rating". Try setting it to the variable rating, and test out your code. If it doesn't work, reply and I'll try to fix your problem...


#3

hi. Thanks for answering. I changed only "rating" to rating (no quotes) That didn't help. I still get the same error.
"in your first when clause of your case statement, when you ask the user what movie title they want to add, you create a new Hash entry with the movie name"

I'm not sure how. Is it because I use " instead of ' ?
And if this is the case, can you explain the difference in ruby?


#4

Hey @marcidenmark,

Try changing your original prompt to the variable choice. Because other than that, your code is identical to mine. I don't know why Ruby is doing this to you :pensive:!


#5

still same hash error, and now I also got : "undefined local variable or method `choice' for #"


#6

Hey @marcidenmark,

can you please post your code and I will be happy to help you.


#7

ovies = {
American_Hustle: 10,
}

puts "What movie title do you want to add?"
title = gets.chomp
case choice

when "add"
puts "Add a movie title."
title = gets.chomp
puts "How do you rate this movie?"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else puts "Error!"
end


#8

Hello @marcidenmark,

Change title = gets.chomp under puts "What movie title do you want to add?" to choice = gets.chomp. This should make it work for you...


#9

maybe it should, but it doesn't. can it be a problem with the website?
movies = {
American_Hustle: 10,
}

puts "What movie title do you want to add?"
title = gets.chomp
case choice

when "add"
puts "Add a movie title."
choice = gets.chomp
puts "How do you rate this movie?"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else puts "Error!"
end


#10

@marcidenmark, you change the whole puts to choice variable, it was meant to be the other one. I cannot post my code, as that will be disobeying community guidelines. Sorry, man...