Recall & Review
beginner
What is a flash message in Rails?
A flash message is a way to send a one-time message from the controller to the view, usually to show notices or alerts after an action like form submission.
Click to reveal answer
beginner
How long does a flash message last in Rails?
Flash messages last for exactly one request cycle. They appear on the next page load and then disappear automatically.
Click to reveal answer
beginner
How do you set a flash message in a Rails controller?
You set a flash message by assigning a string to flash[:key], for example: flash[:notice] = "Saved successfully".
Click to reveal answer
intermediate
What is the difference between flash and flash.now in Rails?
flash sets a message for the next request, while flash.now sets a message for the current request only, useful when rendering instead of redirecting.
Click to reveal answer
beginner
Where in a Rails view do you usually display flash messages?
Flash messages are usually displayed in the application layout or a shared partial, so they appear on any page after an action.
Click to reveal answer
What does flash[:alert] typically represent in Rails?
✗ Incorrect
flash[:alert] is conventionally used to show error or warning messages to the user.
Which method shows a flash message immediately without redirecting?
✗ Incorrect
flash.now sets a flash message for the current request, so it appears immediately when rendering.
Where should you place flash message display code in a Rails app?
✗ Incorrect
Flash messages are shown in views, usually in the main layout or a shared partial for consistency.
What happens to a flash message after it is displayed once?
✗ Incorrect
Flash messages are designed to last only one request cycle and then clear automatically.
How do you set a success flash message in Rails?
✗ Incorrect
flash[:notice] is commonly used for success or informational messages.
Explain how flash messages work in Rails and how you would use them in a simple form submission.
Think about how you tell a user their form was saved or had errors.
You got /4 concepts.
Describe the difference between flash and flash.now and when you would use each.
Consider what happens when you redirect versus render in Rails.
You got /4 concepts.