Class: Workarea::AssetsSeeds

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

Instance Method Summary collapse

Instance Method Details

#load_assets(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/seeds/workarea/assets_seeds.rb', line 10

def load_assets(path)
  if File.directory?(path)
    Dir.glob("#{path}/*.{jpeg,jpg,png,gif}").each do |path|
      filename = path.split('/').last.split('.').first

      Content::Asset.create!(
        name: filename.titleize,
        file: File.new(path),
        alt_text: filename.titleize
      )
    end
  end
end

#performObject



3
4
5
6
7
8
# File 'app/seeds/workarea/assets_seeds.rb', line 3

def perform
  puts 'Adding assets...'

  load_assets("#{Core::Engine.root}/data/content_assets")
  load_assets("#{Rails.root}/data/content_assets")
end