Skip to content

Instantly share code, notes, and snippets.

@chsh
Created September 17, 2012 05:00
Show Gist options
  • Save chsh/3735634 to your computer and use it in GitHub Desktop.
Save chsh/3735634 to your computer and use it in GitHub Desktop.
Use fragment cache in helper method.
module ApplicationHelper
def content_with_cache(key, content)
controller.read_fragment(key) ||
controller.write_fragment(key, content)
end
end
@chsh
Copy link
Author

chsh commented Sep 17, 2012

"cache" method is available. But it doesn't return content. So, we can't embed using equal operator in view file. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment