Challenge - 5 Problems
Named Routes Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What is the output of this Rails view helper call?
Given the following route in
What does
config/routes.rb:resources :articles
What does
article_path(5) return?Attempts:
2 left
💡 Hint
Think about the RESTful route generated by
resources :articles for the show action.✗ Incorrect
The resources :articles creates RESTful routes. The article_path(5) helper generates the path to show the article with ID 5, which is /articles/5.
📝 Syntax
intermediate1:30remaining
Which option correctly defines a named route with a custom path helper?
You want to create a route for
/profile that maps to users#show and use the helper profile_path. Which route definition is correct?Attempts:
2 left
💡 Hint
The
as: option defines the named route helper.✗ Incorrect
Option A correctly uses get with to: and as: to define the named route profile_path.
❓ state_output
advanced1:30remaining
What is the value of
edit_article_path(@article) if @article.id = 10?Assuming standard RESTful routes for articles, what path does
edit_article_path(@article) generate?Attempts:
2 left
💡 Hint
The edit route for a resource appends
/edit after the resource ID.✗ Incorrect
The edit_article_path(@article) helper generates the path to edit the article with ID 10, which is /articles/10/edit.
🔧 Debug
advanced1:30remaining
Why does this route helper call raise an error?
Given the route
resources :comments, what error occurs when calling comment_path without arguments?Ruby on Rails
comment_path
Attempts:
2 left
💡 Hint
Show and other member routes require an ID argument.
✗ Incorrect
The comment_path helper requires an ID to generate the path for a specific comment. Calling it without arguments raises an ArgumentError about missing keys.
🧠 Conceptual
expert2:00remaining
Which option correctly explains the difference between
*_path and *_url helpers?In Rails, what is the main difference between
article_path(1) and article_url(1)?Attempts:
2 left
💡 Hint
Think about what the browser needs to navigate to a page versus what you might send in an email.
✗ Incorrect
_path helpers generate relative paths suitable for links within the app. _url helpers generate full URLs including protocol and host, useful for emails or redirects.