Skip to content

Instantly share code, notes, and snippets.

@fphilipe
Created September 21, 2011 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fphilipe/1232834 to your computer and use it in GitHub Desktop.
Save fphilipe/1232834 to your computer and use it in GitHub Desktop.
Easier access to assets in Rails 3.1
# 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