module
ActionController::UrlWriter
v2.1.0 -
Show latest stable
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.
Files
- actionpack/lib/action_controller/url_rewriter.rb
1Note
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