Sha256: 58033f879423f308376e7282cd0111fded86af8c2555f857aaf923c1893ed205

Contents?: true

Size: 763 Bytes

Versions: 61

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

class AddCoreContentBlocks < ActiveRecord::Migration[5.2]
  class Organization < ApplicationRecord
    self.table_name = :decidim_organizations
  end

  class ContentBlock < ApplicationRecord
    self.table_name = :decidim_content_blocks
  end

  def change
    default_blocks = Decidim.content_blocks.for(:homepage).select(&:default)

    Organization.pluck(:id).each do |organization_id|
      default_blocks.each_with_index do |manifest, index|
        weight = (index + 1) * 10
        ContentBlock.create(
          decidim_organization_id: organization_id,
          weight: weight,
          scope: :homepage,
          manifest_name: manifest.name,
          published_at: Time.current
        )
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
decidim-core-0.27.9 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.8 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.7 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.6 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.10 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.9 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.5 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.8 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.4 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.3 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.7 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.5 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.2 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.1 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.4 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.0 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.3 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.0.rc2 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.27.0.rc1 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.26.2 db/migrate/20180730071851_add_core_content_blocks.rb