Created
June 29, 2011 01:45
-
-
Save ryana/1052736 to your computer and use it in GitHub Desktop.
A simple fragment caching example in Rails 3
This file contains 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
class Conversation | |
#... | |
after_create :expire_dash_cache | |
def add_new_comments(comments) | |
# Do stuff w/ the new comments... | |
save | |
expire_dash_cache | |
end | |
def expire_dash_cache | |
ActionController::Base.new.expire_fragment("dashboard_#{site.id}") | |
end | |
end |
This file contains 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
<% cache("dashboard_#{current_site.id}") do %> | |
<%= render :partial => 'dashboard/conversation_table' %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment