20161124065838_add_templates_to_resolve_url.rb 437 B

12345678910111213141516
  1. class AddTemplatesToResolveUrl < ActiveRecord::Migration[5.0]
  2. def up
  3. Agents::WebsiteAgent.find_each do |agent|
  4. if agent.event_keys.try!(:include?, 'url')
  5. agent.options['template'] = (agent.options['template'] || {}).tap { |template|
  6. template['url'] ||= '{{ url | to_uri: _response_.url }}'
  7. }
  8. agent.save!(validate: false)
  9. end
  10. end
  11. end
  12. def down
  13. # No need to revert
  14. end
  15. end