0

my default image is broken when it tries to load.

my code:

has_attached_file :background, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "default-logo.png"
validates_attachment_content_type :background, :content_type => /\Aimage\/.*\Z/

Rendered:

Failed to load resource: the server responded with a status of 404 (Not Found) http://test.dev/default-logo.png

default-logo.png is located in my assets/images folder. Why is it now showing up?

TuxedoTomson
  • 483
  • 4
  • 16
  • possible duplicate of [Default\_url in Paperclip Broke with Asset Pipeline Upgrade](http://stackoverflow.com/questions/9646549/default-url-in-paperclip-broke-with-asset-pipeline-upgrade) – CDub Oct 23 '14 at 05:49

1 Answers1

2

You need to explicitly set the path in the has_attached_file line of code to tell Paperclip exactly where to look for your default image. What I have used in the past is ActionController::Base.helpers.asset_path, passing in the asset file name.

So, for your code, try:

has_attached_file :background, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => ActionController::Base.helpers.asset_path("default-logo.png")
CDub
  • 13,146
  • 4
  • 51
  • 68