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

Instance Method Details

#article_comment_path(article, comment) ⇒ String

The nested member.

Parameters:

Returns:

  • (String) —

    "/articles/1/comments/2"



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.

Parameters:

Returns:

  • (String) —

    "/articles/1/comments"



431
# File 'docs/api/stubs/generated_app.rb', line 431

def article_comments_path(article); end

#article_path(article) ⇒ String

Returns "/articles/1".

Examples:

redirect_to article_path(@article), status: :see_other

Parameters:

Returns:

  • (String) —

    "/articles/1"



420
# File 'docs/api/stubs/generated_app.rb', line 420

def article_path(article); end

#articles_path ⇒ String

Returns "/articles".

Returns:

  • (String) —

    "/articles"



405
# File 'docs/api/stubs/generated_app.rb', line 405

def articles_path = "/articles"

#articles_url ⇒ String

Returns Cybertrain.url_root + "/articles".

Returns:



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".

Parameters:

Returns:

  • (String) —

    "/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".

Returns:

  • (String) —

    "/articles/new"



413
# File 'docs/api/stubs/generated_app.rb', line 413

def new_article_path = "/articles/new"

#root_path ⇒ String

Returns "/".

Returns:

  • (String) —

    "/"



401
# File 'docs/api/stubs/generated_app.rb', line 401

def root_path = "/"