Intern Track Roadmap

Rails forms: form_with

This course covers form_with, the Rails helper this project uses for forms bound to a model. It shows how form_with model: picks the HTTP method and button label for new and saved records. It explains how the form builder generates fields with inferred name, id and value. It traces a field named article[title] through the request body into params[:article][:title] and article_params. It follows the same chain through the project's identity settings form and explains the authenticity token that protects against CSRF.

What you'll learn

  • ✓How form_with model: builds forms for new and saved records
  • ✓How f.text_field and f.submit infer name, id, value and label from the model
  • ✓How bracketed field names become nested params such as params[:article][:title]
  • ✓How param_key connects the identity settings form to settings_params
  • ✓What the authenticity token does against CSRF
Free preview · Lesson 1 1 min read

From generated tags to a generated form

ActionController: actions showed a form's fields arriving as params[:article][:title] without showing what sent them. Controller params & security opened article_params, params.require(:article).permit(:title), without showing where the nested :article key comes from. Both pointed at the same gap:…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...