Class: PixelFire::Tag
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PixelFire::Tag
- Defined in:
- app/models/pixel_fire/tag.rb
Instance Method Summary collapse
Instance Method Details
#update_triggers(trigger_ids) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/pixel_fire/tag.rb', line 8 def update_triggers(trigger_ids) trigger_ids ||= [] current_ids = .pluck(:trigger_id) unchanged_ids = trigger_ids & current_ids || [] new_ids = trigger_ids - unchanged_ids remove_ids = current_ids - unchanged_ids .where(trigger_id: remove_ids).map(&:destroy) if remove_ids.present? new_ids.each do |trigger_id| .create(trigger_id: trigger_id) end end |