- 1.0.0
- 1.1.0
- 1.1.1
- 1.1.6
- 1.2.0 (0)
- 1.2.6 (0)
- 2.0.0 (0)
- 2.0.1 (0)
- 2.0.3 (0)
- 2.1.0 (0)
- 2.2.1 (34)
- 2.3.2 (0)
- 2.3.8 (0)
- 3.0.0 (-38)
- 3.0.5 (0)
- 3.0.7 (0)
- 3.0.9 (0)
- 3.1.0
- 3.2.1
- 3.2.3
- 3.2.8
- 3.2.13
- What's this?
Write URLs from arbitrary places in your codebase, such as your mailers.
Example:
class MyMailer include ActionController::UrlWriter default_url_options[:host] = 'www.basecamphq.com' def signup_url(token) url_for(:controller => 'signup', action => 'index', :token => token) end end
In addition to providing url_for, named routes are also accessible after including UrlWriter.
Accessing URL helpers in Rails 3
I’ve been upgradings an app to Rails 3 and it took me a bit to find this-
If you were using
include ActionController::UrlWriter
to get the url helpers in rails 2, you should switch to
include Rails.application.routes.url_helpers
for Rails 3
From: http://snipplr.com/view/37063/to-access-url-helpers-urlfor-etc-from-rails-console-rails-3/
How to deal with Missing host to link to!
You just need to define default_url_options[:host] in your class. The easiest way to do it:
class SomeClass include ActionController::UrlWriter default_url_options[:host] = YourApp::Application.config.action_mailer.default_url_options[:host] def some_method some_superb_url(maybe_even_some_variable_here) end end


