> On Mar 6, 2019, at 9:27 AM, Walter Lee Davis <waltd@wdstudio.com> wrote:
>
>>
>> On Mar 6, 2019, at 7:15 AM, Colin Law <clanlaw@gmail.com> wrote:
>>
>> I hope someone can help me with an assets problem. I have had to
>> rebuild a production server and images are no longer getting served.
>> Unfortunately the working system is no more so I can't compare what I
>> have with what used to work in order to help diagnose the problem.
>>
>> I am using Rails 4.2 with nginx on an Ubuntu 16.04 server with
>> capistrano to deploy it and I have not changed the application (which
>> is git controlled). However it is now running on a later version of
>> Ubuntu so the tools there have been updated, including nginx.
>>
>> The problem is that image assets are not being served, the javascript
>> and css are working. I can see (on the server) that the assets have
>> been precompiled and I can see in public/assets image files such as
>> blue_pin-<digest>.png where <digest> is a big long number.
>> However in the browser console I can see it attempt to fetch
>> /assets/blue_pin.png without the digest, and this fails.
>>
>> The code in the app that references the image is in coffescript and is a line
>> @marker_icon_blue = new OpenLayers.Icon('/assets/blue_pin.png', size, offset);
>>
>> I used to know how all this is supposed to work, but I have been away
>> from Rails for a while and the brain cells seem to have atrophied
>> rather, and perusing the docs has failed to re-invigorate them
>> sufficiently, so if someone could suggest what might be going on I
>> would be very grateful.
>>
>> Colin
>
> The asset pipeline needs a JavaScript interpreter to work correctly on the server. I usually install whatever version of Node.js is available in a package manager. Alternatively, you can use the gem `therubyracer` to do the same thing. If you have that dependency filled, then I'm fresh out of ideas.
>
> Walter
Other than, of course, making sure you have sprockets and sprockets-rails listed in your Gemfile.lock. But you said you had run the rake assets:precompile task, or at least I assumed you had, if you said that your assets were precompiled already. Make sure that this works, on the server:
RAILS_ENV=production rake assets:precompile
If you do that, and you don't get any errors, you'll have two possible outcomes:
1. You'll get an output line for each asset (maybe two lines, with one being .gz of the previous).
2. You'll get nothing at all (this is okay and normal, it means that the assets did not change since the last invocation of the command).
If you started up a new server, it may have a different secret key or assets version, and that would change the fingerprints on all the precompiled assets. Running the precompile step again would fix that.
Walter
--
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/D57C1273-E186-4B74-9D94-7D3E854E0FCE%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment