Sha256: 58a4cc1d44a8b090cefb0a7b7a7b4db58f2b30f42996cb8645c3380ff9ed8110

Contents?: true

Size: 546 Bytes

Versions: 34

Compression:

Stored size: 546 Bytes

Contents

module Workarea
  class AssetsSeeds
    def perform
      puts 'Adding assets...'

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

    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)
          )
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.44 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.43 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.42 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.41 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.40 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.39 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.38 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.37 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.36 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.35 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.34 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.33 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.32 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.31 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.30 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.29 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.28 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.27 app/seeds/workarea/assets_seeds.rb
workarea-core-3.4.26 app/seeds/workarea/assets_seeds.rb