class PublishedPage < ApplicationRecord extend FriendlyId friendly_id :title, :use => :slugged belongs_to :all_page belongs_to :article, optional: true def published true end def created_name Admin.find(self.created_by).description end def created_date self.created_at.to_date end def article_friendly ret = '' if self.type_of == 3 && self.article pp = self.article.published_pages.where('type_of = 2').first unless pp.blank? ret = pp.friendly_id end end return ret end end