Skip to content
Snippets Groups Projects
Commit 178c3d36 authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch 'collection_thumbnail' into 'master'

modify collection serializer to return first 4 items' thumbnails

See merge request !362
parents a02a5004 ad12e14d
No related branches found
No related tags found
No related merge requests found
......@@ -24,4 +24,9 @@ class CollectionItem < ApplicationRecord
def recipient
collection
end
def thumbnail
collectionable_type == 'LearningObject' ? LearningObject.find(collectionable_id).default_thumbnail : Collection.find(collectionable_id).thumbnail
end
end
......@@ -13,7 +13,15 @@ class CollectionSerializer < ActiveModel::Serializer
object.complained? current_user
end
attributes :id, :name, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :liked, :reviewed, :complained, :review_average, :thumbnail
def items_thumbnails
thumbs = []
object.collection_items[0..3].each do | t |
thumbs << t.thumbnail
end
thumbs
end
attributes :id, :name, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :liked, :reviewed, :complained, :review_average, :thumbnail, :items_thumbnails
belongs_to :owner
has_many :tags
has_many :subjects
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment