Sha256: 87a4ca0e783d367ffe72a5bf9ca4c24879915c707c0b53236e72b0ac93efefd0
Contents?: true
Size: 1.02 KB
Versions: 16
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true class MoveOrganizationFieldsToHeroContentBlock < ActiveRecord::Migration[5.2] class Organization < ApplicationRecord self.table_name = :decidim_organizations mount_uploader :homepage_image, ::Decidim::HomepageImageUploader end def change Decidim::ContentBlock.reset_column_information Organization.find_each do |organization| content_block = Decidim::ContentBlock.find_by(organization: organization, scope: :homepage, manifest_name: :hero) settings = {} welcome_text = organization.welcome_text || {} settings = welcome_text.inject(settings) { |acc, (k, v)| acc.update("welcome_text_#{k}" => v) } content_block.settings = settings content_block.images_container.background_image = organization.homepage_image.file content_block.settings_will_change! content_block.images_will_change! content_block.save! end remove_column :decidim_organizations, :welcome_text remove_column :decidim_organizations, :homepage_image end end
Version data entries
16 entries across 16 versions & 1 rubygems