Test Your Knowledge

Quiz

  1. How much information should you store in cookies?

  2. How do you specify how long a cookie will last?

  3. Where does Rails normally store the information you put in the cookie object?

  4. What does calling flash.now do?

Answers

  1. You should store as little information in cookies as your application can manage.

  2. Cookie lifespans default to expiring when the user quits the browser, but can be set to more specific lengths of time with the :expires parameter.

  3. By default, Rails stores the cookie objects information directly in the cookie, on the user’s browser, but note that you can change this by modifying your config/environment.rb file.

  4. The flash.now method lets you set a value to be sent to the user, but ensures that the value will be cleared before any reloads or redirects.

Get Learning Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.