Sha256: 3969fca7af72342d98a6a34b429dfb38f70e23fd89abc03d1eca0474b0046514

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

Comable::Sample.import('products')

suede_dress = Comable::Product.where(name: Comable::Sample.t(:suede_dress)).first!
girly_coat = Comable::Product.where(name: Comable::Sample.t(:girly_coat)).first!
fur_gloves = Comable::Product.where(name: Comable::Sample.t(:fur_gloves)).first!
leather_boots = Comable::Product.where(name: Comable::Sample.t(:leather_boots)).first!

def image(name, suffix: '.jpg')
  image_path = File.join(File.dirname(__FILE__), 'images', name + suffix)
  File.open(image_path)
end

images_attributes = [
  {
    product: suede_dress,
    file: image('suede_dress')
  },
  {
    product: suede_dress,
    file: image('suede_dress_full')
  },
  {
    product: girly_coat,
    file: image('girly_coat')
  },
  {
    product: fur_gloves,
    file: image('fur_gloves')
  },
  {
    product: leather_boots,
    file: image('leather_boots')
  },
  {
    product: leather_boots,
    file: image('leather_boots_front')
  },
  {
    product: leather_boots,
    file: image('leather_boots_back')
  }
]

images_attributes.each do |attributes|
  Comable::Image.create!(attributes)
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
comable-sample-0.7.1 db/samples/images.rb
comable-sample-0.7.0 db/samples/images.rb
comable-sample-0.7.0.beta2 db/samples/images.rb
comable-sample-0.7.0.beta1 db/samples/images.rb
comable-sample-0.6.0 db/samples/images.rb
comable_sample-0.5.0 db/samples/images.rb
comable_sample-0.4.2 db/samples/images.rb