kreeti / kt-paperclip

Easy file attachment management for ActiveRecord
Other
275 stars 95 forks source link

Attachment default_url should allow nil #55

Open johnnyshields opened 3 years ago

johnnyshields commented 3 years ago

If I set Paperclip::Attachment.default_options[:default_url] = nil (instead of missing.png) Paperclip gives an error. This PR allows setting to nil, without changing any existing default behavior.

sbhawsingka commented 3 years ago

Hi @johnnyshields, thanks for the PR!

Your fix looks good, however, one small concern

image_tag user.avatar.url(:medium)

will lead to the following error - Nil location provided. Can't build URI.

So this change will hamper the ability to follow the common pattern of using the image_tag as shown in the above example.

If the purpose of this PR is only to render nothing in place of a missing image, maybe, we should avoid returning nil from the library so that the common code pattern shown above works safely.