Skip to content

Instantly share code, notes, and snippets.

@clemens
Created January 29, 2009 08:53
Show Gist options
  • Save clemens/54473 to your computer and use it in GitHub Desktop.
Save clemens/54473 to your computer and use it in GitHub Desktop.
class SectionsCell < BaseCell
tracks_cache_references :recent_articles, :track => ['@section', '@articles']
exposes_states :recent_articles => {
:name => 'Recent articles',
:description => 'A cell containing a given number of recent articles, optionally from a certain section.'
}
def recent_articles
# TODO make these before filters
symbolize_options!
set_site
set_section
@count = @opts[:count] || 5
@articles = with_sections_scope(Article) do
Article.all(:limit => @count, :order => "published_at DESC")
end
nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment