Created
September 21, 2011 18:09
-
-
Save fphilipe/1232834 to your computer and use it in GitHub Desktop.
Easier access to assets in Rails 3.1
This file contains hidden or 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
# coding: UTF-8 | |
# A module to facilitate the retrieval of asset paths and urls in Rails 3.1. | |
module Assets | |
extend self | |
def url(file) | |
host + path(file) | |
end | |
def path(file) | |
Rails.application.assets.path(file, true, prefix) | |
end | |
def prefix | |
Rails.configuration.assets.prefix | |
end | |
def host | |
Rails.configuration.action_controller.asset_host | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment