I can’t figure out what I’m doing wrong here.
I can’t seem to get the #{@user.name} to work in my flash[:notice]
Everything else works just fine I can add new users, but when I add a new user instead of saying “User John Doe was successfully created”, it says “User #{@user.name} was successfully created.”
I’m at this point in the depot app: depot_p/app/controllers/users_controller.rb to work.
This has to do with string interpolation which is for double quoted strings only, it has nothing to do with the flash.
You can substitute the value of any Ruby expression into a double quoted string using the sequence
#{ expr }. If the expression is just a global variable, a class variable, or an instance variable, you can omit the braces.For more info, Programming Ruby is a free Ruby online book.