Complete the code to create a link to the home page with the text 'Home'.
<%= link_to 'Home', [1] %>
home_url when the path helper is expected.index_path or main_url.The link_to helper creates a link. Using root_path points to the home page route.
Complete the code to create a link to the user's profile page using the user object.
<%= link_to 'Profile', [1] %>
user_profile_path or profile_path which may not exist.The standard RESTful route for a user's show page is user_path(user).
Fix the error in the code to generate a link that opens in a new tab safely.
<%= link_to 'Docs', docs_url, [1] %>
rel: 'noopener' when using target: '_blank'.target: '_self' which opens in the same tab.To open a link in a new tab safely, use target: '_blank' and add rel: 'noopener' to prevent security risks.
Fill both blanks to create a link with a CSS class and a data attribute.
<%= link_to 'Delete', post_path(post), [1]: 'delete', [2]: 'btn btn-danger' %>
data instead of method for HTTP method.style instead of class for CSS classes.The method: 'delete' option tells Rails to send a DELETE request. The class: 'btn btn-danger' adds CSS classes for styling.
Fill all three blanks to create a link with a confirmation dialog, CSS class, and HTTP method.
<%= link_to 'Logout', logout_path, [1]: 'delete', [2]: 'btn btn-warning', [3]: { confirm: 'Are you sure?' } %>
data and method options.method: 'delete' sends a DELETE request, class: 'btn btn-warning' styles the link, and data: { confirm: 'Are you sure?' } shows a confirmation popup.