config/routes.rb:resources :articles
What does
article_path(5) return?resources :articles for the show action.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.
/profile that maps to users#show and use the helper profile_path. Which route definition is correct?as: option defines the named route helper.Option A correctly uses get with to: and as: to define the named route profile_path.
edit_article_path(@article) if @article.id = 10?edit_article_path(@article) generate?/edit after the resource ID.The edit_article_path(@article) helper generates the path to edit the article with ID 10, which is /articles/10/edit.
resources :comments, what error occurs when calling comment_path without arguments?comment_path
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.
*_path and *_url helpers?article_path(1) and article_url(1)?_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.
