0
0
Ruby on Railsframework~10 mins

View helpers 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 use a Rails view helper that creates a link to the home page.

Ruby on Rails
<%= link_to 'Home', [1] %>
Drag options to blanks, or click blank then click option'
Ahome_url
Broot_path
Cindex_path
Dmain_page
Attempts:
3 left
💡 Hint
Common Mistakes
Using a URL helper instead of a path helper
Using a non-existent helper name
2fill in blank
medium

Complete the code to safely display user input in a view using a Rails helper.

Ruby on Rails
<%= [1](user_input) %>
Drag options to blanks, or click blank then click option'
Araw
Bescape_once
Chtml_safe
Dsanitize
Attempts:
3 left
💡 Hint
Common Mistakes
Using raw which outputs unsafe HTML
Using html_safe on untrusted input
3fill in blank
hard

Fix the error in the code to correctly display a formatted date using a Rails view helper.

Ruby on Rails
<%= [1](user.created_at, format: :short) %>
Drag options to blanks, or click blank then click option'
Aformat_time
Bdate_format
Cl
Dformat_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent helpers like format_date
Confusing with strftime which is a Ruby method, not a helper
4fill in blank
hard

Fill both blanks to create a form input field with a label using Rails view helpers.

Ruby on Rails
<%= [1] :user, :email %>
<%= [2] :user, :email %>
Drag options to blanks, or click blank then click option'
Alabel
Btext_field
Cemail_field
Dform_for
Attempts:
3 left
💡 Hint
Common Mistakes
Using text_field instead of email_field for email inputs
Mixing up the order of label and input helpers
5fill in blank
hard

Fill all three blanks to create a link that opens in a new tab with Rails view helpers.

Ruby on Rails
<%= link_to [1], [2], [3]: '_blank' %>
Drag options to blanks, or click blank then click option'
A'Google'
B'https://www.google.com'
Ctarget
Drel
Attempts:
3 left
💡 Hint
Common Mistakes
Using rel instead of target for opening in new tabs
Not quoting the link text or URL