I'm using Paperclip in my rails app to upload images to the filesystem. I furthermore use single table inheritance for an Incident model. Damage inherits from Incident. When I now create a new Incident object of :type => 'Damage' with a photo attached, something strange happens:
- object.class --> Damage
- object.url --> "/system/damages/photo_images/000/000/265/original/my_image.png?1441880763"
object.path --> "/Users/fuzz/keeja/backend/keeja_backend/public/system/damages/photo_images/000/000/265/original/fav_icon.png"
has_attached_file :photo_image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
And now comes the strange part. The actual path of the uploaded file is not one of the above, but: /Users/fuzz/keeja/backend/keeja_backend/public/system/incidents/photo_images/000/000/265/original/fav_icon.png"
So Paperclip stores the file under a different path on the file system, than object.path says.
Can anyone please help me find out what's going wrong here?
Damages.new
/Damages.create
/ etc orIncidents.new
/Incidents.create
/ etc? It sounds like you may be working with the abstract class, not a subclass. Try directly creating an instance of the subclass if not. – madcow