Class: PostsService

Inherits:
Object
  • Object
show all
Defined in:
app/services/posts_service.rb

Class Method Summary collapse

Class Method Details


2
3
4
5
6
7
8
# File 'app/services/posts_service.rb', line 2

def self.featured
  ids = Blog.where(featured: true).map do |b|
    b.posts.order('created_at DESC').pluck(:id).first
  end

  Post.where(id: ids)
end