Class: LatestArticles

Inherits:
Noodall::Component
  • Object
show all
Defined in:
app/models/latest_articles.rb

Instance Method Summary collapse

Instance Method Details

#articlesObject

Returns a filtered list of latest articles



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/latest_articles.rb', line 11

def articles
  return [] if article_list.nil?
  query = {
    categories: category,
    order: ['published_at DESC','created_at DESC']
  }

  # Remove any filters that are set to "All"
  query.reject! {|key, value| value == "All" || value.blank? }

  article_list.children.published.limit(3).all(query)
end

#categoriesObject



24
25
26
# File 'app/models/latest_articles.rb', line 24

def categories
  Article.all_categories
end