Junior Track Roadmap

Strong parameters: expect

This course covers params.expect in Rails strong parameters. It starts with the array tampering bug: a string where a hash is expected crashes require and permit, and a hash where an array is expected passes through with the wrong shape. The lessons read this app's expect line, explain the double-bracket syntax for arrays of hashes, and show multiple root keys with destructuring. They also cover expect! and Rails' exact class-name status lookup. They then migrate a require/permit controller and compare its output.

What you'll learn

  • ✓How expect combines require and permit in one call
  • ✓Why tampered payloads crash or slip through require and permit
  • ✓The double-bracket syntax for arrays of hashes and empty brackets for scalar arrays
  • ✓Multiple root keys in one expect call, destructured into variables
  • ✓How expect! differs from expect and why it maps to a 500
  • ✓Migrating a require/permit controller and testing valid and missing-key payloads
Free preview · Lesson 1 3 min read

The bug params.expect exists to fix

Controller params & security ended by setting expect aside: how require and permit work on their own, and how expect's single call replaces both, was left for a dedicated course, this one. Everything that course taught about require and permit still holds. This course is about expect itself.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...