Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 init.rb
README
current_request - maurício DOT linhares AT gmail DOT com
====

This plugin sets the current Rails request object in a Thread local variable
so you can use it in places where the controller (and thus the request) are not
directly available.

The most common case for this are the e-mail templates, where sometimes you need
to render a link but you don't have access to the current request to add the
host. With this plugin you'll have the request at the e-mail templates and
will be able to find out the current host to add a link to it:

<%= link_to 'Home', "#{current_request.protocol}#{current_request.host_with_port}/home" %>

Or you can just use a shorthand to the current host:

<%= link_to 'Home', "#{current_host}/home" %>

You can also use it wherever you want to access the current request
(and not only on templates) by calling:

  CurrentRequest::Holder.current_request

You can install the plugin by calling:

ruby script/plugin install git://github.com/mauricio/current_request.git
Something went wrong with that request. Please try again.