Created
October 6, 2010 22:16
-
-
Save drogus/614204 to your computer and use it in GitHub Desktop.
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 ArticlesPart < Parts::Base | |
def index | |
return if fragment_exist?([:articles_part, Article.last]) | |
@articles = Articles.recent | |
render | |
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
class EventsPart < Parts::Base | |
def index | |
# this is lazy loaded, so no need to check fragment cache | |
@events = Event.limit(10) | |
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([:events_part, Event.last]) do %> | |
<ul> | |
<% @events.each do |event| %> | |
<li><%= link_to event.name, [event] %></li> | |
<% end %> | |
</ul> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment