Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Render Rails assets to string
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
@niyando

This comment has been minimized.

Copy link

commented Jun 3, 2016

this doesn't work with assets with erb extension .. for eg.. blabla.js.erb
It does render, but the embedded ruby remains un-executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.