I have a bunch of jpeg files in a folder on my server, and I'm trying to attach them to their respective instances Propertyusing the rake command.
property.rb has the following code:
has_attached_file :temp_photo,
:styles => PropertyImage::STYLES,
:url => "/assets/:class/:attachment/:id_partition/:style_:basename.:extension",
:path => "#{Rails.root}/public/assets/:class/:attachment/:id_partition/:style_:basename.:extension"
I use paperclip for other models and there are no problems, but I have a problem when I try to do the following:
p = Property.find(id)
file = File.open(temp_file_path)
p.temp_photo = file
p.save
file.close
p.errors
The file definitely exists, and I tried to change the permissions. Restarting the server does not help. The problem seems to be related to using the command line, as the normal form / HTTP method works fine. This is only a temporary setup, so I'm looking for an efficient way to import a package of files into my rails paperclip model.
Any suggestions?
source
share