views:

350

answers:

1

I'm trying to use the default_url in my application but I store the images using S3. I'm not sure what URL I need to put in there or if I have to create a fake image just to get everything up there.

Since my images always render through S3, I don't know if it would work if I just put in some default images in my public folder. It doesn't seem to be working now - I also only have one image in there, and I know it has to resize. I can manually put the resized images in there but I'm still not sure what URL to use with default. Please help :)

+2  A: 

I use paperclip with S3 with default images in the public folder. It works fine. My default_url statement looks like this:

:default_url => '/images/:attachment/missing_:style.png'

which means that for my attachment named avatar, setup with the styles small and large, I must create and put these images in the public dir:

  • /images/avatar/missing_small.png
  • /images/avatar/missing_large.png

It's pretty well documented.

For your reference, or in the case the problem is really somewhere else, here is my full paperclip statement:

has_attached_file :avatar,
  :styles => { :small => '60x60#', :large => '300x300#' }, :default_style => :large,
  :storage => :s3,
  :default_url => '/images/:attachment/missing_:style.png',
  :path => "users/:id/avatar/:style.:extension",
  :bucket => "bucket name",
  :s3_credentials => {
    :access_key_id => "access key id",
    :secret_access_key => "secret access key"
  },
  :url => ":s3_alias_url", # These two are only required when you alias S3 - e.g. want to use cdn.example.com rather than s3.amazonaws.com
  :s3_host_alias => "my.aws.alias"
Casper Fabricius