Module: Gen::UrlHelpers
- Defined in:
- docs/api/stubs/generated_app.rb
Overview
The *_path and *_url helpers spin run gen writes into
gen/routes.rb, one pair per named route in config/routes.rb. They are
included into every controller and resolved by name in templates. These
are the ones examples/blog’s routes generate:
Cybertrain::Routes.draw do
root "articles#index"
resources :articles do |articles|
articles.resources :comments, only: [:create, :destroy]
end
end
Arguments are positional, one per :param in the path: a record (its
to_param, the id), an Integer or a String,
percent-encoded as one segment. nil raises ArgumentError "missing route
parameter". There is no hash form and no query-string option; append
"?page=2" yourself. *_url prepends Cybertrain.url_root.
See Cybertrain::Routes.draw for the names each route gets.
Instance Method Summary collapse
-
#article_comment_path(article, comment) ⇒ String
The nested member.
-
#article_comments_path(article) ⇒ String
The nested collection: one argument per level.
-
#article_path(article) ⇒ String
"/articles/1". -
#articles_path ⇒ String
"/articles". -
#articles_url ⇒ String
Cybertrain.url_root +
"/articles". -
#edit_article_path(article) ⇒ String
"/articles/1/edit". -
#new_article_path ⇒ String
"/articles/new". -
#root_path ⇒ String
"/".
Instance Method Details
#article_comment_path(article, comment) ⇒ String
The nested member.
438 |
# File 'docs/api/stubs/generated_app.rb', line 438 def article_comment_path(article, comment); end |
#article_comments_path(article) ⇒ String
The nested collection: one argument per level.
431 |
# File 'docs/api/stubs/generated_app.rb', line 431 def article_comments_path(article); end |
#article_path(article) ⇒ String
Returns "/articles/1".
420 |
# File 'docs/api/stubs/generated_app.rb', line 420 def article_path(article); end |
#articles_path ⇒ String
Returns "/articles".
405 |
# File 'docs/api/stubs/generated_app.rb', line 405 def articles_path = "/articles" |
#articles_url ⇒ String
Returns Cybertrain.url_root + "/articles".
409 |
# File 'docs/api/stubs/generated_app.rb', line 409 def articles_url = Cybertrain.url_root + articles_path |
#edit_article_path(article) ⇒ String
Returns "/articles/1/edit".
425 |
# File 'docs/api/stubs/generated_app.rb', line 425 def edit_article_path(article); end |
#new_article_path ⇒ String
Returns "/articles/new".
413 |
# File 'docs/api/stubs/generated_app.rb', line 413 def new_article_path = "/articles/new" |
#root_path ⇒ String
Returns "/".
401 |
# File 'docs/api/stubs/generated_app.rb', line 401 def root_path = "/" |