Complete the code to display the user's name in the view.
<h1>Welcome, [1]!</h1>In Rails views, you use <%= %> to embed Ruby code that outputs data. Here, @user.name is displayed with <%= %>.
Complete the code to loop through all posts and show their titles in the view.
<ul> <% @posts.each do |[1]| %> <li><%= [1].title %></li> <% end %> </ul>
The block variable inside each do |...| should be singular to represent each item. Here, post is correct.
Fix the error in the code to correctly display the user's email.
<p>Email: [1]</p>To display data in a Rails view, use <%= %> with the instance variable @user.email.
Fill both blanks to create a link to the user's profile with the user's name as link text.
<%= link_to [1], [2] %>
link_to takes the link text first, then the path. Here, @user.name is the text, and user_path(@user) is the URL.
Fill all three blanks to display a list of product names with prices formatted as currency.
<ul> <% @products.each do |[1]| %> <li><%= [2] %> - <%= number_to_currency([3]) %></li> <% end %> </ul>
The block variable is product. Use product.name for the name and product.price for the price formatted with number_to_currency.