class ProductPhoto < ActiveRecord::Base
belongs_to :product
has_attached_file :photo, styles: {large: '1024x1024', medium: '300x300', small: '150x150#', item: '150x'}
validates_attachment_content_type :photo, content_type: /\Aimage/
validates :photo, presence: true
end
# in rails console
ProductPhoto.all.each do |pp|
pp.photo = File.open("#{Rails.root}/app/assets/images/example-image.png", "rb")
pp.save
end