Test Your Knowledge

Quiz

  1. How can you sanitize information being passed to a SQL query so it can’t harm your database?

  2. What’s the simplest way to keep user-entered data from attacking other users’ browsers?

  3. How does switching to production mode affect caching?

  4. Where do you make changes to Rails’ production database configuration?

Answers

  1. Specifying the :conditions parameter as an array makes Rails take a closer look at incoming data to ensure that isn’t potentially damaging SQL.

  2. Applying the h method to all outgoing content is the simplest way to ensure that nothing awful gets through, though stripping all HTML tags is another similarly effective option.

  3. Rails caches heavily in production mode, helping you to maximize throughput while minimizing processing time.

  4. The config/database.yml file is the place to specify database information, including the type of database, where to connect to the database, and any authentication information.

Get Learning Rails: Live Edition 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.