Avoid assets disappearing on you

22 views
Skip to first unread message

Fernando Cordeiro

unread,
Dec 15, 2015, 1:57:36 AM12/15/15
to Ruby on Rails: Talk
My problem is fairly simple, and I am more than 100% sure more people have issues with it.


First of all, let's be clear, I am not quite "new" to rails, I have been working steadily with it for over a year (And I love it), and I do a lot of more advanced stuff, so I am not unfamiliar with the asset pipeline at all.


But one of the things that I always get back to is the assets pipeline, and using it for more "permanent" assets like logos.


The Asset Pipeline is amazing and I'm all for opinionated solutions, but I'm all for solutions, and the decision to not use querystrings, albeit respectable in the sense it leverages proxies, creates a problem where mails sent today may appear without a logo in the near future.


I am not saying this should change (unless all or at least most caching proxies started picking up query strings, if that's the case maybe changing is a good idea). I'm just looking for a solution to serve (At least some of) the assets that were deleted by using the newest version, even with different digests. I had to upload files to the public folder more than a few times, and I feel like it's an awful way to fix it.


Now, having estabilished I do understand the Rails way and I am only trying to devise a way to keep serving files, what is the general opinion about it, and are there already ways to achieve it?


Thanks, and nice to "meet" you all. :D

Frederick Cheung

unread,
Dec 15, 2015, 3:12:56 AM12/15/15
to Ruby on Rails: Talk
On Tuesday, December 15, 2015 at 6:57:36 AM UTC, Fernando Cordeiro wrote:

>
> The Asset Pipeline is amazing and I'm all for opinionated solutions, but I'm all for solutions, and the decision to not use querystrings, albeit respectable in the sense it leverages proxies, creates a problem where mails sent today may appear without a logo in the near future.
>
> I am not saying this should change (unless all or at least most caching proxies started picking up query strings, if that's the case maybe changing is a good idea). I'm just looking for a solution to serve (At least some of) the assets that were deleted by using the newest version, even with different digests. I had to upload files to the public folder more than a few times, and I feel like it's an awful way to fix it.
>

The standard way to solve this (if serving the assets directly) is to symlink public/assets to a folder that persists across deploys - this way old assets remain available. If you use Capistrano to deploy your apps this is done with you (and they also provide a rake task for deleting assets that haven't been deployed in over a certain (configurable) time.

Fred

Colin Law

unread,
Dec 15, 2015, 3:27:59 AM12/15/15
to Ruby on Rails: Talk
On 15 December 2015 at 08:12, Frederick Cheung
<frederic...@gmail.com> wrote:
> On Tuesday, December 15, 2015 at 6:57:36 AM UTC, Fernando Cordeiro wrote:
>
>>
>> The Asset Pipeline is amazing and I'm all for opinionated solutions, but I'm all for solutions, and the decision to not use querystrings, albeit respectable in the sense it leverages proxies, creates a problem where mails sent today may appear without a logo in the near future.
>>
>> I am not saying this should change (unless all or at least most caching proxies started picking up query strings, if that's the case maybe changing is a good idea). I'm just looking for a solution to serve (At least some of) the assets that were deleted by using the newest version, even with different digests. I had to upload files to the public folder more than a few times, and I feel like it's an awful way to fix it.
>>
>
> The standard way to solve this (if serving the assets directly) is to symlink public/assets to a folder that persists across deploys - this way old assets remain available. If you use Capistrano to deploy your apps this is done with you (and they also provide a rake task for deleting assets that haven't been deployed in over a certain (configurable) time.

An even better solution to your problem with emails is not to embed
linked images in emails. Many, many people have image download
disabled in their email viewer (possibly gmail defaults to this mode,
not sure). Also the images are not available when viewing email
offline.

Colin

jel...@gmail.com

unread,
Dec 15, 2015, 8:13:54 AM12/15/15
to rubyonra...@googlegroups.com
This takes away from the OPs original request. I've not heard that most people have image download turned off but ok.

I think the best option is to symlink public/assets across a persisted directory as the other gent said. This is how I do it and it works pretty well.

Sent from my iPhone
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtsRqY1q4s9%3DGO-QMnost57ijD_1gQihJpmK5%2B9pdNXrQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

nanaya

unread,
Dec 15, 2015, 8:22:33 AM12/15/15
to rubyonra...@googlegroups.com


On Tue, Dec 15, 2015, at 22:13, jel...@gmail.com wrote:
> This takes away from the OPs original request. I've not heard that most
> people have image download turned off but ok.
>

quite sure it's off by default in many clients. I personally almost
never turn on (remote) images on email.

> I think the best option is to symlink public/assets across a persisted
> directory as the other gent said. This is how I do it and it works pretty
> well.
>

The other alternative is to inline the images using `attachments.inline`
(and this way the images will usually be shown because it's not a local
resource).
Reply all
Reply to author
Forward
0 new messages