Skip to content

Commit

Permalink
Fixed hardcoded post tag query attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
owen2345 committed Oct 2, 2017
1 parent 50a516c commit ed919b4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/models/concerns/camaleon_cms/categories_tags_for_posts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def update_categories(cats=[])
def update_tags(tags)
rescue_extra_data
tags = tags.split(",").strip
post_tags = self.post_type.post_tags
post_tags = post_tags.where("name not in (?)", tags) if tags.present?
self.term_relationships.where("term_taxonomy_id in (?)", post_tags.pluck("#{CamaleonCms::TermTaxonomy.table_name}.id")).destroy_all
post_tags = post_type.post_tags
post_tags = post_tags.where.not(name: tags) if tags.present?
term_relationships.where("term_taxonomy_id in (?)", post_tags.pluck("#{CamaleonCms::TermTaxonomy.table_name}.id")).destroy_all
tags.each do |f|
post_tag = self.post_type.post_tags.where({name: f}).first_or_create(slug: f.parameterize)
self.term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create
post_tag = post_type.post_tags.where({name: f}).first_or_create(slug: f.parameterize)
term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create
end
update_counters("tags")
end
Expand Down

0 comments on commit ed919b4

Please sign in to comment.