Class: PixelFire::Trigger
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PixelFire::Trigger
- Defined in:
- app/models/pixel_fire/trigger.rb
Instance Method Summary collapse
Instance Method Details
#update_tags(tag_ids) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/pixel_fire/trigger.rb', line 24 def (tag_ids) tag_ids ||= [] current_ids = .pluck(:tag_id) unchanged_ids = tag_ids & current_ids new_ids = tag_ids - unchanged_ids remove_ids = current_ids - unchanged_ids .where(tag_id: remove_ids).map(&:destroy) if remove_ids.present? new_ids.each do |tag_id| .create(tag_id: tag_id) end end |