Module: Padrino::Routing::InstanceMethods

Overview

Instance methods related to recognizing and processing routes and serving static files.

Instance Method Summary

Instance Method Details

#absolute_url(*args) ⇒ Object

Returns absolute url. Calls Sinatra::Helpers#uri to generate protocol version, hostname and port.

Examples:

absolute_url(:show, :id => 1)  # => http://example.com/show?id=1
absolute_url(:show, 24)        # => https://example.com/admin/show/24
absolute_url('/foo/bar')       # => https://example.com/admin/foo/bar
absolute_url('baz')            # => https://example.com/admin/foo/baz

#content_type(type = nil, params = {}) ⇒ Object

Return the request format, this is useful when we need to respond to a given Content-Type.

Examples:

get :index, :provides => :any do
  case content_type
    when :js    then ...
    when :json  then ...
    when :html  then ...
  end
end

Parameters:

  • type (Symbol, nil) (defaults to: nil)
  • params (Hash) (defaults to: {})

#current_path(*path_params) ⇒ Object

Returns the current path within a route from specified path_params.

#recognize_path(path) ⇒ Object

#route ⇒ Object

Returns the current route

Examples:

-if route.controller == :press
  %li=show_article

#static!(options = {}) ⇒ Object

Method for deliver static files.

#static_file?(path_info) ⇒ Boolean

This is mostly just a helper so request.path_info isn't changed when serving files from the public directory.

Returns:

  • (Boolean)

#url(*args) ⇒ Object Also known as: url_for

Instance method for URL generation.

Examples:

url(:show, :id => 1)
url(:show, :name => :test)
url(:show, 1)
url("/foo", false, false)

See Also: