Skip to content
Snippets Groups Projects
Commit 5c89aa32 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

Merge branch 'fix-collection_item_serializer' into 'master'

CollectionMinSerializer

See merge request !334
parents 04a047ae 523a9683
No related branches found
No related tags found
No related merge requests found
class CollectionItemSerializer < ActiveModel::Serializer class CollectionItemSerializer < ActiveModel::Serializer
cache key: 'collection_item', expires_in: 24.hours cache key: 'collection_item', expires_in: 24.hours
def collectionable def collectionable
serializer = object.collectionable_type == "LearningObject" ? ::LearningObjectSerializer : ::CollectionSerializer serializer = object.collectionable_type == "LearningObject" ? ::LearningObjectSerializer : ::CollectionMinSerializer
serializer.new(object.collectionable, {scope: current_user, scope_name: :current_user}).serializable_hash serializer.new(object.collectionable, {scope: current_user, scope_name: :current_user}).serializable_hash
end end
belongs_to :collectionable, polymorphic: true belongs_to :collectionable, polymorphic: true
......
class CollectionMinSerializer < ActiveModel::Serializer
cache key: 'collection', expires_in: 4.hours
attributes :id, :name, :owner, :created_at, :updated_at, :description, :privacy, :score, :likes_count, :review_average, :thumbnail
has_many :tags
has_many :subjects
has_many :educational_stages
end
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