0
0
Ruby on Railsframework~10 mins

Model-backed forms in Ruby on Rails - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a form for a model instance named @post.

Ruby on Rails
<%= form_with model: [1] do |form| %>
  <!-- form fields here -->
<% end %>
Drag options to blanks, or click blank then click option'
Apost
Bform
CPost.new
D@post
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name instead of the instance variable.
Using a local variable instead of the instance variable.
2fill in blank
medium

Complete the code to create a text field for the :title attribute inside the form builder.

Ruby on Rails
<%= form.text_field [1] %>
Drag options to blanks, or click blank then click option'
A:date
B:content
C:title
D:author
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong attribute name.
Omitting the colon before the attribute name.
3fill in blank
hard

Fix the error in the form helper call to correctly submit the form.

Ruby on Rails
<%= form_with model: @post, [1]: true do |form| %>
  <!-- form fields -->
<% end %>
Drag options to blanks, or click blank then click option'
Alocals
Blocal
Clocales
Dlocalize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' without the colon.
Using misspelled keys like 'locales' or 'locals'.
4fill in blank
hard

Fill both blanks to create a label and a text field for the :email attribute.

Ruby on Rails
<%= form.label [1] %>
<%= form.text_field [2] %>
Drag options to blanks, or click blank then click option'
A:email
B:name
C:username
D:password
Attempts:
3 left
💡 Hint
Common Mistakes
Using different attributes for label and field.
Forgetting the colon before the attribute name.
5fill in blank
hard

Fill all three blanks to create a form with a model, a label for :password, and a password field.

Ruby on Rails
<%= form_with model: [1] do |form| %>
  <%= form.label [2] %>
  <%= form.password_field [3] %>
<% end %>
Drag options to blanks, or click blank then click option'
A@user
B:password
D:email
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing attribute symbols for label and field.
Using the wrong instance variable for the model.