def create
# 登録用
product = Product.new(name: params['name'], price: params['price'], description: params['description'])
if params[:image]
extension = File.extname(params[:image].original_filename)
random_filename = SecureRandom.uuid + extension
product.image = random_filename
image = params[:image]
File.binwrite("public/products/#{product.image}", image.read)
else
product.image = "defalut.png"
end
if product.save
flash[:notice] = "出品に成功しました"
redirect_to('/home/top')
else
flash[:notice] = "出品に失敗しました"
render("products/sell")
end
end