Class: Workarea::BrowsingPagesSeeds

Inherits:
Object
  • Object
show all
Defined in:
app/seeds/workarea/browsing_pages_seeds.rb

Instance Method Summary collapse

Instance Method Details

#find_unique_nameObject

TODO remove in v3.5 as this is no longer used



22
23
24
25
26
27
28
29
30
31
# File 'app/seeds/workarea/browsing_pages_seeds.rb', line 22

def find_unique_name
  department = Faker::Commerce.department(1)
  pages = Content::Page.all.to_a

  until pages.select { |p| p.name == department }.empty?
    department = Faker::Commerce.department(1)
  end

  department
end

#performObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/seeds/workarea/browsing_pages_seeds.rb', line 3

def perform
  puts 'Adding browsing pages...'

  Workarea.config.default_seeds_taxonomy.each do |top_level, children|
    page = Content::Page.create!(name: top_level, tag_list: 'browsing')
    content = Content.for(page)

    children.each do |category|
      content.blocks.build(
        type: :category_summary,
        data: { category: Catalog::Category.find_by(name: category).id }
      )
    end

    content.save!
  end
end