Skip to content

Commit

Permalink
Change SEO data retrieve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nirosh ubeysinghe committed Sep 22, 2020
1 parent d8c28b4 commit 66142d7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/fi_seo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def update_dynamic_seo_record
self.create_dynamic_seo_record
else
DynamicSeo.where(seoable_type: self.class.to_s).where(seoable_id: self.id)
.update_all(title: self.dynamic_seo.title, description: self.dynamic_seo.description, keywords: self.dynamic_seo.keywords)
.update_all(title: self.title_value, description: self.description_value, keywords: self.keywords_value)
end
end
end
Expand Down Expand Up @@ -189,15 +189,27 @@ def canonical_url
end

def title_value
self.send(self.class.seoable_fields.first)
if self&.dynamic_seo&.title.present?
self.dynamic_seo.title
else
self.send(self.class.seoable_fields.first)
end
end

def description_value
self.send(self.class.seoable_fields.second)
if self&.dynamic_seo&.description.present?
self.dynamic_seo.description
else
self.send(self.class.seoable_fields.second)
end
end

def keywords_value
self.send(self.class.seoable_fields.third)
if self&.dynamic_seo&.keywords.present?
self.dynamic_seo.keywords
else
self.send(self.class.seoable_fields.third)
end
end
end
end
Expand Down

0 comments on commit 66142d7

Please sign in to comment.