Sha256: da43d4b7f99e2bdb7c47fc5fd96dfbee95fe04321ff697731b7da5ac5900b546
Contents?: true
Size: 771 Bytes
Versions: 4
Compression:
Stored size: 771 Bytes
Contents
Comable::Sample.import('categories') clothing = Comable::Category.where(name: Comable::Sample.t(:clothing)).first! products_attributes = [ { name: Comable::Sample.t(:suede_dress), price: 6_990, categories: [clothing] }, { name: Comable::Sample.t(:girly_coat), price: 9_000, categories: [clothing] }, { name: Comable::Sample.t(:fur_gloves), price: 5_292, categories: [clothing] }, { name: Comable::Sample.t(:leather_boots), price: 28_080, categories: [clothing] } ] next_id = (Comable::Product.maximum(:id) || 0).next products_attributes.each.with_index(next_id) do |attributes, index| code = format('%05d', index) Comable::Product.create!(attributes.merge(code: code, published_at: Date.today)) end
Version data entries
4 entries across 4 versions & 1 rubygems