20221110150329_issue_4322_session_timeout_stringify.rb 763 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue4322SessionTimeoutStringify < ActiveRecord::Migration[6.1]
  3. def up
  4. return if !Setting.exists?(name: 'system_init_done')
  5. setting = Setting.find_by name: 'session_timeout'
  6. setting.options['form'].each do |form_option|
  7. form_option['options'].each do |option|
  8. option['value'] = option['value'].to_s
  9. end
  10. end
  11. %i[state_current state_initial].each do |attr|
  12. migrate_attribute setting, attr
  13. end
  14. setting.save!
  15. end
  16. def migrate_attribute(object, attr)
  17. hash = object.send(attr)
  18. hash['value'].each_key do |key|
  19. hash['value'][key] = hash['value'][key].to_s
  20. end
  21. object.send(:"#{attr}=", hash)
  22. end
  23. end