Permalink
Browse files

Finished setting up first of the demo seeds.

  • Loading branch information...
1 parent 0cb4381 commit 2fe4558c72ad1bf902907495413f3ac888ccf54b @Jellyfishboy committed Jun 28, 2016
@@ -60,7 +60,7 @@ class Product < ActiveRecord::Base
validates :meta_description, length: { maximum: 150, message: :too_long }, :if => :published?
validates :name, length: { minimum: 10, message: :too_short }, :if => :published?
validates :description, length: { minimum: 20, message: :too_short }, :if => :published?
- validates :short_description, length: { maximum: 150, message: :too_long }, :if => :published?
+ validates :short_description, length: { maximum: 300, message: :too_long }, :if => :published?
validates :part_number, numericality: { only_integer: true, greater_than_or_equal_to: 1 }, :if => :published?
accepts_nested_attributes_for :skus
@@ -1,17 +1,16 @@
puts '-----------------------------'
puts 'Executing product seeds'.colorize(:green)
-# Computing
+# file = File.read('public/demo_assets/products.json')
+# json = JSON.parse(file)
+yaml = YAML.load_file('lib/demo_assets/products.yml')
-file = File.read('public/demo_assets/products.json')
-json = JSON.parse(file)
-
-json.each do |product|
+yaml.each do |product|
category = Category.find_by_slug(product['category'])
# create product
new_product = category.products.build(
- part_number: product['part_number'],
+ part_number: Faker::Number.number(6),
name: product['name'],
description: product['description'],
short_description: product['short_description'],
@@ -48,9 +47,9 @@
)
end
- img_files = Dir.chdir(Rails.root.join("public/demo_assets/#{product['category']}/#{product['id']}/")){ Dir.glob("**/*") }
+ img_files = Dir.chdir(Rails.root.join("lib/demo_assets/#{product['category']}/#{product['id']}/")){ Dir.glob("**/*") }
img_files.each do |file_name|
- new_product.attachments.create(file: File.open(File.join(Rails.root, "public/demo_assets/#{product['category']}/#{product['id']}/", file_name)))
+ new_product.attachments.create(file: File.open(File.join(Rails.root, "lib/demo_assets/#{product['category']}/#{product['id']}/", file_name)))
end
new_product.attachments.first.update_column(:default_record, true)
new_product.published!
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,234 @@
+---
+ -
+ id: 1
+ category: "computing"
+ name: "Acer DVI HDMI Monitor"
+ short_description: "Acer KA0 Series LED-backlit monitors deliver stunningly detailed images in a Full HD 1080p resolution."
+ description: "With a native screen resolution of 1920 x 1080 pixels the Acer KA0 Series LED-backlit monitors deliver stunningly detailed images in a Full HD 1080p resolution. The great sights are made even better by exceptional colours via Adaptive Contrast Management (ACM), ensuring crystal clear viewing und an ultra-high contrast ratio of 100 million:1. Designed with eco-friendliness in mind, these monitors are recyclable and packaged in a manner that reduces excess plastics and waste. The KA0 Series also makes use of no restricted substances and is designed for minimal power consumption. Thanks to these features, the KA0 Series monitors were recognized as ENERGY STAR® 6.0 qualified, TCO certified."
+ meta_description: "Acer KA0 Series LED-backlit monitors deliver stunningly detailed images in a Full HD 1080p resolution."
+ page_title: "Acer HD DVI HDMI Monitor"
+ weighting: "1000"
+ sku: "KA"
+ featured: false
+ single: false
+ active: true
+ skus:
+ -
+ variant_type: "Size"
+ code: "22\""
+ price: 76.98
+ cost_value: 34.88
+ length: 220
+ width: 220
+ thickness: 20
+ weight: 5
+ -
+ variant_type: "Size"
+ code: "24\""
+ price: 87.22
+ cost_value: 44.12
+ length: 240
+ width: 240
+ thickness: 20
+ weight: 7
+ -
+ id: 2
+ category: "computing"
+ name: "Epson EB-S04 SVGA Projector"
+ short_description: "High-quality, mobile projector for the home and office with 3LCD technology, SVGA resolution and flexible, easy-to-use features."
+ description: "The whole family will enjoy this high-quality, versatile projector. Whether watching films and family photos on a big screen or delivering crisp, clear presentations, the stylishly-designed EB-S04 is ideally suited for both the home and office. Easy to move and quick to set-up, users can start watching exceptional-quality content in no time at all. Create a spectacular cinema-style occasion for friends and family and enjoy high-quality images on a huge screen up to 300+ inches1. Films, sporting events and once-in-a-lifetime spectacles will all appear sharp and clear thanks to a high Colour Light Output (CLO), meaning colours are bright and vivid, even in brightly-lit rooms or outdoors. In fact, Epson projectors are up to three times brighter than competitor 1-chip DLP projectors2. With a wide range of options available, Epson is sure to have the right projector to deliver the ultimate viewing experience."
+ meta_description: "High-quality, mobile projector for the home and office with 3LCD technology, SVGA resolution and flexible, easy-to-use features."
+ page_title: "Epson EB-S04 SVGA Projector"
+ weighting: "2000"
+ sku: "EBS04"
+ featured: false
+ single: false
+ active: true
+ skus:
+ -
+ variant_type: "Color"
+ code: "Black"
+ price: 252.99
+ cost_value: 113.88
+ length: 100
+ width: 100
+ thickness: 20
+ weight: 8
+ -
+ variant_type: "Color"
+ code: "Silver"
+ price: 250.99
+ cost_value: 111.88
+ length: 100
+ width: 100
+ thickness: 20
+ weight: 9
+ -
+ id: 1
+ category: "storage"
+ name: "Seagate 3.5\" SATA Desktop Hard Drive"
+ short_description: "The Seagate® HDD is the one hard drive for all your desktop applications. One drive for every need, supported by 30 years of trusted performance."
+ description: "Seagate Desktop HDD, 1TB-per-disk technology incorporates 340,000 unique tracks in the width of a single inch. This incredible storage density drives new capacity possibilities and lowers your total storage costs. Seagate AcuTrac™ technology enables storage densities with accurate reading and writing to nano-sized tracks only 75 nanometres wide! That is about 500 times smaller than the full stop at the end of this sentence. Seagate Desktop HDDs are the world's most popular desktop storage solutions. With consistent quality and performance-enhancing innovations and features such as native command queuing and perpendicular recording, Seagate delivers time and time again. In addition, Seagate Desktop HDDs are produced using the most sophisticated manufacturing process in the industry, with a focus on environmental stewardship."
+ meta_description: "The Seagate® HDD is the one hard drive for all your desktop applications. One drive for every need, supported by 30 years of trusted performance."
+ page_title: "Seagate 3.5\" SATA Desktop Hard Drive"
+ weighting: "1000"
+ sku: "SGSATA"
+ featured: false
+ single: false
+ active: true
+ skus:
+ -
+ variant_type: "Size"
+ code: "1TB"
+ price: 42.99
+ cost_value: 12.58
+ length: 50
+ width: 50
+ thickness: 10
+ weight: 5
+ -
+ variant_type: "Size"
+ code: "2TB"
+ price: 60.99
+ cost_value: 18.78
+ length: 50
+ width: 50
+ thickness: 10
+ weight: 5
+ -
+ variant_type: "Size"
+ code: "3TB"
+ price: 84.99
+ cost_value: 27.55
+ length: 50
+ width: 50
+ thickness: 10
+ weight: 5
+ -
+ id: 2
+ category: "storage"
+ name: "Kingston Class 4 MicroSDHC Card - With Adapter"
+ short_description: "microSDHC cards offer higher storage for more music, more videos, more pictures, more games - more of everything you need in today's mobile world."
+ description: "microSDHC cards offer higher storage for more music, more videos, more pictures, more games - more of everything you need in today's mobile world. The microSDHC card allows you to maximize today's revolutionary mobile devices. Kingston's microSDHC cards use the new speed \"class\" rating of Class 4 that guarantee a minimum data transfer rate of 4MB/sec. for optimum performance with devices that use microSDHC. Identical in physical size to today's standard microSD card, the microSDHC cards are designed to comply with SD Specification Version 2.00 and are only recognized by microSDHC host devices. They can be used as full-size SDHC cards when used with the included adapter. To ensure compatibility, look for the microSDHC or SDHC logo on host devices (e.g. phones, PDAs, and cameras)."
+ meta_description: "microSDHC cards offer higher storage for more music, more videos, more pictures, more games - more of everything you need in today's mobile world."
+ page_title: "Kingston Class 4 MicroSDHC Card - With Adapter"
+ weighting: "2000"
+ sku: "KGSDHC"
+ featured: false
+ single: false
+ active: true
+ skus:
+ -
+ variant_type: "Size"
+ code: "4GB"
+ price: 2.19
+ cost_value: 0.20
+ length: 10
+ width: 10
+ thickness: 10
+ weight: 1
+ -
+ variant_type: "Size"
+ code: "8GB"
+ price: 7.20
+ cost_value: 2.20
+ length: 10
+ width: 10
+ thickness: 10
+ weight: 1
+ -
+ variant_type: "Size"
+ code: "16GB"
+ price: 12.88
+ cost_value: 4.22
+ length: 50
+ width: 50
+ thickness: 10
+ weight: 5
+ -
+ variant_type: "Size"
+ code: "32GB"
+ price: 19.78
+ cost_value: 8.11
+ length: 10
+ width: 10
+ thickness: 10
+ weight: 1
+ -
+ id: 1
+ category: "software"
+ name: "Windows 10 Home OEM"
+ short_description: "Windows 10 is the best ever - familiar, easy to use, and packed with great new features for staying organized, having fun, and getting things done. It's the Windows you love - and the Windows you can't wait to get."
+ description: "Windows 10 is so familiar and easy to use, you'll feel like an expert. The Start menu is back in an expanded form, plus we'll bring over your pinned apps and favorites so they're ready and waiting for you. It starts up and resumes fast, has more built-in security to help keep you safe, and is designed to work with software and hardware you already have."
+ meta_description: "Windows 10 is the best ever - familiar, easy to use, and packed with great new features."
+ page_title: "Windows 10 Home OEM"
+ weighting: "1000"
+ sku: "WIN10"
+ featured: false
+ single: false
+ active: true
+ skus:
+ -
+ variant_type: "Size"
+ code: "32BIT"
+ price: 70.99
+ cost_value: 10.50
+ length: 10
+ width: 10
+ thickness: 10
+ weight: 1
+ -
+ variant_type: "Size"
+ code: "62BIT"
+ price: 73.98
+ cost_value: 13.50
+ length: 10
+ width: 10
+ thickness: 10
+ weight: 1
+ -
+ id: 1
+ category: "components"
+ name: "EVGA GeForce G210 1GB DDR3 VGA DVI HDMI PCI-E Graphics Card"
+ short_description: "There are many benefits to the EVGA G210 1GB DDR3 VGA DVI HDMI PCI-E Graphic Card and some of these are that this card has a resolution of (Max Digital) 2560 x1600 (Dual Link DVI Only) under D-Sub (max resolution) and 2048 x 1536 DVI (max resolution)."
+ description: "There are many benefits to the EVGA G210 1GB DDR3 VGA DVI HDMI PCI-E Graphic Card and some of these are that this card has a resolution of (Max Digital) 2560 x1600 (Dual Link DVI Only) under D-Sub (max resolution) and 2048 x 1536 DVI (max resolution). The Brand name EVGA has a reputation for reliability and quality of components, it has has many reviews as a leading manufacturer. EVGA is a name that is known and respected by gamers worldwide, whether thay are using Radeon or Nvidea GPU's. The power of this card is not immediately apparent because it is passively cooled, however this card will run most games with ease and can run some of the latest games at lower resolutions. The card comes out of the box with 1024 Mb of memory onboard and is ready to run most titles with ease. So whether you are looking for graphic card which will be an ideal gaming companion or a component to drive your favourite movies onto the screen the EVGA G210 1GB DDR3 VGA DVI HDMI PCI-E Graphic Card is the perfect choice in the new entry market."
+ meta_description: "There are many benefits to the EVGA G210 1GB DDR3 VGA DVI HDMI PCI-E Graphic Card."
+ page_title: "EVGA GeForce G210 1GB DDR3 VGA DVI HDMI PCI-E Graphics Card"
+ weighting: "1000"
+ sku: "G210"
+ featured: false
+ single: true
+ active: true
+ skus:
+ -
+ variant_type: "Size"
+ code: "1GB"
+ price: 21.99
+ cost_value: 4.66
+ length: 50
+ width: 50
+ thickness: 10
+ weight: 2
+ -
+ id: 2
+ category: "components"
+ name: "Noctua NF-F12 PWM 120mm Focused Flow PWM Cooling Fan"
+ short_description: "Designed for pressure demanding applications such as heatsinks and radiators, the Focused Flow frame features eleven stator guide vanes that straighten, channel and focus the airflow. This allows the NF-F12 to rival the performance of conventional fans running at much faster speeds."
+ description: "By teaming up eleven stator guide vanes with a specially conceived seven blade impeller, the NF-F12's Focused Flow system creates outstanding static pressure and focuses the airflow for superior performance on heatsinks and radiators. At the same time, a wide range of advanced aerodynamic design measures, second generation SSO bearings and Noctua's new, custom designed PWM IC for fully automatic control guarantee astounding quietness of operation. The NF-F12 comes with modular cabling, integrated anti-vibration pads and two speed settings for full flexibility. Its commanding performance, exhaustive set of features and Noctua's trusted premium quality make it an elite choice for use on air coolers, radiators and other pressure demanding applications."
+ meta_description: "Noctua NF-F12 PWM 120mm Focused Flow PWM Cooling Fan"
+ page_title: "Noctua NF-F12 PWM 120mm Focused Flow PWM Cooling Fan"
+ weighting: "1000"
+ sku: "NF-F"
+ featured: false
+ single: true
+ active: true
+ skus:
+ -
+ variant_type: "Size"
+ code: "120mm"
+ price: 21.99
+ cost_value: 4.66
+ length: 50
+ width: 50
+ thickness: 10
+ weight: 2
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 2fe4558

Please sign in to comment.