0
0
Ruby on Railsframework~10 mins

Why forms drive user interaction in Ruby on Rails - Test Your Understanding

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

Complete the code to create a form that submits data in Rails.

Ruby on Rails
<%= form_with url: '/submit', method: '[1]' do %>
  <%= label_tag :name %>
  <%= text_field_tag :name %>
  <%= submit_tag 'Send' %>
<% end %>
Drag options to blanks, or click blank then click option'
Aput
Bget
Cpost
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST for submitting form data.
2fill in blank
medium

Complete the code to add a text input field named 'email' inside the form.

Ruby on Rails
<%= form_with url: '/subscribe', method: 'post' do %>
  <%= label_tag :email %>
  <%= [1] %>
  <%= submit_tag 'Subscribe' %>
<% end %>
Drag options to blanks, or click blank then click option'
Atext_field_tag :email
Bemail_field_tag :email
Cpassword_field_tag :email
Dcheck_box_tag :email
Attempts:
3 left
💡 Hint
Common Mistakes
Using password_field_tag or check_box_tag for email input.
3fill in blank
hard

Fix the error in the form helper to correctly create a form for a @user object.

Ruby on Rails
<%= form_with model: [1] do |form| %>
  <%= form.label :username %>
  <%= form.text_field :username %>
  <%= form.submit 'Save' %>
<% end %>
Drag options to blanks, or click blank then click option'
AUser
Busers
Cuser
D@user
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the class name or a symbol instead of the instance variable.
4fill in blank
hard

Fill both blanks to create a form that submits to the 'create' action with POST method and includes a hidden authenticity token.

Ruby on Rails
<%= form_with url: [1], method: [2] do %>
  <%= hidden_field_tag :authenticity_token, form_authenticity_token %>
  <%= submit_tag 'Submit' %>
<% end %>
Drag options to blanks, or click blank then click option'
A'/users'
B'post'
C'get'
D'/login'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET method or wrong URL path.
5fill in blank
hard

Fill all three blanks to build a form that edits a @post object, uses PATCH method, and includes a text area for content.

Ruby on Rails
<%= form_with model: [1], method: [2] do |form| %>
  <%= form.label :content %>
  <%= form.[3] :content %>
  <%= form.submit 'Update' %>
<% end %>
Drag options to blanks, or click blank then click option'
A@post
B'patch'
Ctext_area
D'post'
Etext_field
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of PATCH or text_field instead of text_area.