Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Construct absolute paths and full URLs to actions in a Sinatra application
Ruby
tree: bf59ca88f0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/sinatra
spec
.document
.gitignore
LICENSE
README.rdoc
Rakefile

README.rdoc

sinatra-url-for

sinatra-url-for can be used by a Sinatra application to construct absolute paths and full URLs. For example:

gem 'emk-sinatra-url-for'
require 'sinatra/url_for'

# From within a request.
url_for "/"            # Returns "/myapp/"
url_for "/foo"         # Returns "/myapp/foo"
url_for "/foo", :full  # Returns "http://example.com/myapp/foo"

If you're subclassing Sinatra::Base, then you need to call helpers manually:

class MyApp < Sinatra::Base
  helpers Sinatra::UrlForHelper
  # ...
end

Thanks to “cypher23” on #mephisto and the folks on #rack for pointing me in the right direction.

Copyright

Copyright 2009 Eric Kidd. See LICENSE for details.

Something went wrong with that request. Please try again.