Using Rails url helpers in models

by Trevor Turk

If you need to use the Rails url helpers in a model for some reason, here’s an easy way:

You need to specify the host, or else you’ll get an “undefined method” error, which can be a bummer.