Created
September 29, 2010 06:46
-
-
Save lsemel/602380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This class gives you all the Rails 3 URL helpers, which are so | |
# unhelpfully unavailable in models, libraries, and unit tests | |
# Stick this in the library folder and get a URL with | |
# UrlHelpers.new.nameofmodel_url | |
class UrlHelpers | |
include Rails.application.routes.url_helpers | |
def initialize | |
default_url_options[:host] = case Rails.env | |
when "development" then "localhost" | |
when "production" then "yourdomain.com" | |
when "test" then "localhost" | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment