fix minor bugs
This commit is contained in:
parent
ea10e38551
commit
1336cb995b
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
ENV["RAILS_ENV"] ||= "development"
|
||||
require File.dirname(__FILE__) + "/../config/environment"
|
||||
ENV['RAILS_ENV'] ||= 'development'
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
|
||||
# import images from old presta shop
|
||||
# images needs to be stored in public/tmp/original
|
||||
|
||||
class PsImage < ApplicationRecord
|
||||
self.table_name = 'ps_image'
|
||||
establish_connection :prestashop_old
|
||||
|
|
@ -16,12 +15,12 @@ path = "#{Rails.root}/public/tmp/original/"
|
|||
ps_images.each do |pi|
|
||||
file = "#{path}#{pi.id_product}-#{pi.id_image}.jpg"
|
||||
puts "#{file} - #{File.exist?(file)}"
|
||||
if File.exist?(file)
|
||||
next unless File.exist?(file)
|
||||
image = Image.new
|
||||
f = File.open(file)
|
||||
image.image = f
|
||||
f.close
|
||||
image.imageable_type = "Product"
|
||||
image.imageable_type = 'Product'
|
||||
image.imageable_id = pi.id_product
|
||||
image.position = pi.position
|
||||
image.cover = pi.cover
|
||||
|
|
@ -29,5 +28,4 @@ ps_images.each do |pi|
|
|||
image.active = true
|
||||
image.save
|
||||
puts "saved: #{image.id}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
|
||||
# This file should contain all the record creation needed to seed the
|
||||
# database with its default values.
|
||||
# The data can then be loaded with the rails db:seed command
|
||||
# (or created alongside the database with db:setup).
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
||||
# movies =
|
||||
# Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
||||
# Character.create(name: 'Luke', movie: movies.first)
|
||||
|
||||
admin = Admin.new
|
||||
|
|
|
|||
Loading…
Reference in New Issue