clemens (owner)

Revisions

gist: 54473 Download_button fork
public
Public Clone URL: git://gist.github.com/54473.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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