From d1c79372d76f5ad96bf30125e62bdc629a1bfcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 5 Apr 2017 18:45:01 +0200 Subject: [PATCH] fix permalinks serializer with subfolder setups --- app/serializers/permalink_serializer.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/serializers/permalink_serializer.rb b/app/serializers/permalink_serializer.rb index 98f2062f795..467e07c5864 100644 --- a/app/serializers/permalink_serializer.rb +++ b/app/serializers/permalink_serializer.rb @@ -1,31 +1,34 @@ class PermalinkSerializer < ApplicationSerializer - attributes :id, :url, :topic_id, :topic_title, :topic_url, :post_id, :post_url, :post_number, :post_topic_title, :category_id, :category_name, :category_url, :external_url + attributes :id, :url, :topic_id, :topic_title, :topic_url, + :post_id, :post_url, :post_number, :post_topic_title, + :category_id, :category_name, :category_url, :external_url def topic_title - object.try(:topic).try(:title) + object&.topic&.title end def topic_url - object.try(:topic).try(:url) + object&.topic&.url end def post_url - object.try(:post).try(:url) + # use `full_url` to support subfolder setups + object&.post&.full_url end def post_number - object.try(:post).try(:post_number) + object&.post&.post_number end def post_topic_title - object.try(:post).try(:topic).try(:title) + object&.post&.topic&.title end def category_name - object.try(:category).try(:name) + object&.category&.name end def category_url - object.try(:category).try(:url) + object&.category&.url end end