0
0
Ruby on Railsframework~10 mins

Passing data to partials 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 render a partial named '_item.html.erb'.

Ruby on Rails
<%= render [1] %>
Drag options to blanks, or click blank then click option'
Atemplate: 'item'
Bpartial: 'item'
Cpartial: :item
D'item'
Attempts:
3 left
💡 Hint
Common Mistakes
Including the underscore in the partial name.
Using 'template' instead of just the partial name string.
2fill in blank
medium

Complete the code to pass a local variable named 'item' to the partial.

Ruby on Rails
<%= render 'item', [1]: {item: @item} %>
Drag options to blanks, or click blank then click option'
Alocals_hash
Blocal
Clocals
Dlocals:
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' instead of 'locals'.
Adding a colon after 'locals' incorrectly.
3fill in blank
hard

Fix the error in passing a local variable named 'user' to the partial.

Ruby on Rails
<%= render 'profile', locals: [1] %>
Drag options to blanks, or click blank then click option'
A{user}
B{user: user}
Cuser
Duser: user
Attempts:
3 left
💡 Hint
Common Mistakes
Passing just the variable without a hash.
Using curly braces without key-value pairs.
4fill in blank
hard

Fill the blank to pass two local variables 'post' and 'comments' to the partial.

Ruby on Rails
<%= render 'post', [1]: {post: post, comments: comments} %>
Drag options to blanks, or click blank then click option'
Alocals
Blocal
Clocals_hash
Dlocals:
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' instead of 'locals'.
Repeating the option name for each variable.
5fill in blank
hard

Fill the blank to render a partial with local variables 'article', 'author', and 'tags'.

Ruby on Rails
<%= render 'article', [1]: {article: article, author: author, tags: tags} %>
Drag options to blanks, or click blank then click option'
Alocals
Barticle
Cauthor
Dtags
Attempts:
3 left
💡 Hint
Common Mistakes
Not using the locals option.
Passing variables without keys.