def self.create(img, prod) filename = "pr#{prod}_" + File.basename(img.original_filename()) fs_path = "/home/rene/ruby/virtual/public/images/products/" + filename thumb_fs_path = "/home/rene/ruby/virtual/public/images/products/thumb_" + filename File.open(fs_path, "w") do |f| f.write(img.read) end create_thumbnail(fs_path, thumb_fs_path, 100, 100) @picture = Picture.new() @picture[:product_id] = prod @picture[:picture_fs_path] = fs_path @picture[:picture_web_path] = "/images/products/" + filename @picture[:thumb_fs_path] = thumb_fs_path @picture[:thumb_web_path] = "/images/products/thumb_" + filename @picture.save end