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

adding ratting name in review_rating_serializer and adding rated and approves in review_serializer

parent e94f6164
No related branches found
No related tags found
No related merge requests found
class ReviewRatingSerializer < ActiveModel::Serializer
def rating_name
object.rating.name
end
attributes :id, :review_id, :rating_id, :rating_name, :value
end
class ReviewSerializer < ActiveModel::Serializer
attributes :id, :name, :description, :pros, :cons, :rates_count, :created_at, :updated_at, :reviewable
def rating_average
object.rating_average
end
def rated
object.rated?(current_user)
end
def approves
object.user_approves? current_user
end
attributes :id, :name, :description, :pros, :cons, :rating_average, :rates_count, :created_at, :updated_at, :reviewable, :rated, :approves
has_many :review_ratings
belongs_to :user
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