When I create a user model the avatar.png file gets properly uploaded to S3 in the defined path. Problem is that, when I try to “read/download” the user.avatar.url it always gives the default path i.e. default avatar.
My user.rb has this:
attr_accessible :avatar
has_attached_file :avatar,
:storage => :s3,
:bucket => "/avatars",
:s3_credentials => {
:access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET']
},
:path => "/avatars/:filename",
:default_url => "https://s3.amazonaws.com/avatars/default.png"
In my view I have:
user.avatar.url #<--- Which outputs https://s3.amazonaws.com/avatars/default.png
Any ideas how to get the right url and the right avatar (which does exists in S3)?
Or how to debug the attachment search path (i.e. the path where paperclip searches the file)?
The problem was that attachments file_name attribute didn’t get saved and that was due to this line:
Removing that line fixed the problem.