Created
May 23, 2012 13:45
-
-
Save riyad/2775306 to your computer and use it in GitHub Desktop.
Render Rails assets to string
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
module ApplicationHelper | |
# thanks to http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/ | |
# you may need to change the owner of the tmp/cache/* directories to the web servers user | |
# e.g. for Debian systems: `chown -R www-data:www-data tmp/cache/*` | |
def render_asset(asset) | |
Conferator::Application.assets.find_asset(asset).body.html_safe | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this doesn't work with assets with erb extension .. for eg.. blabla.js.erb
It does render, but the embedded ruby remains un-executed.