BF.Safouen
BF.Safouen

Reputation: 71

Can't upload image with Paperclip in Ruby on Rails

I'm working on a simple api using ruby on rails, and tried to attach an image to my post but I always get this error:

"[paperclip] Link failed with File exists @ syserr_fail2_in - C:/Users/Safouene/AppData/Local/Temp/d5e01d9478f9774f9f669fd29da0cb2720190401-5260-1tjlj3v.png; copying link C:/Users/Safouene/AppData/Local/Temp/d5e01d9478f9774f9f669fd29da0cb2720190401-5260-ooex8h.png to C:/Users/Safouene/AppData/Local/Temp/d5e01d9478f9774f9f669fd29da0cb2720190401-5260-1tjlj3v.png Command :: file -b --mime "C:/Users/Safouene/AppData/Local/Temp/d5e01d9478f9774f9f669fd29da0cb2720190401-5260-1tjlj3v.png"" Completed 204 No Content in 65ms (ActiveRecord: 1.0ms)

Here is My Model :

class Action < ApplicationRecord
  belongs_to :user 
  validates :title ,presence: true
  validates :desc ,presence: true 
  validates :location , presence: true 
  has_attached_file :picture 
  validates_attachment :picture, presence: true
  do_not_validate_attachment_file_type :picture
end

Upvotes: 0

Views: 215

Answers (1)

Brad
Brad

Reputation: 8668

This is not strictly answering your question but I feel I should point out that since the release of active storage with rails 5.2 many of these file upload gems have been deprecated. This means they will no longer be maintained. (see github page https://github.com/thoughtbot/paperclip)

With that in mind I would strongly advise you to use active storage, rather than paperclip.

Active storage is part of the rails core framework now so you can rest assured it will be maintained and always work the the latest releases of rails.

Plus, active storage is super easy to implement and full of really cool features.

You can read more about active storage here: https://edgeguides.rubyonrails.org/active_storage_overview.html

Upvotes: 1

Related Questions