How to Asset Pre-compile for Production operation? - Rails 4.2.5

Quick query…
I’ve used the excellent “Getting Started with Rails” tutorial to build
the
demo app, Weblog. Has turned out to be a useful tool on our small Lan.
I am using it daily to capture stuff I want to reference across many
devices/tablets, etc. (Windows, Linux, Android, iOS-iPad, etc…)

In production mode, the Destroy/delete and image display did not work
until
I modified the “production.rb” file to allow live compile of assets.
This meant toggle parameter setting “config.assets.compile = false” to
be
“config.assets.compile = true”. Then, the website (which is built
and deployed on a CentOS 6.6 Linux box) would work correctly, as
expected.

But hey, why not precompile my small assets? I read the
incomprehensible
doc on the rails “Asset Pipeline”, and found nothing that
would actually tell me how the precompile my image assets and my little
bit
of .js stuff. (jquery.js and jquery_ujs are needed for Destroy/delete
to actually work).

But in reviewing the postings here, I found this: “rake
assets:precompile”. Ah. I ran this, and got what looked like good
results.
It returned the asset file names, with their MD5 hash strings, and
indicated they are slotted into
…/Weblog/public/assets/imagefilename-(big
long hex hash).jpg
Well, great! Just what I needed (or so I thought in my sad and foolish
ignorance…)

When I run the website, of course I get crap. I get the filenames, with
the big hex hash string, shown on the webpage, instead of the
actual image! Arrrgh! Of course there is some secret hipster bit of
trickery, that I need to deploy, to have a return to sanity and
correct operation of my little website. Peradventure, someone might
enlighten me as to WTF this actually is?

When I ran “rake asset:precompile”, I did get a response indicating
everything was successfully precompiled. But the FAIL behaviour
of my website has returned - ie. filenames are shown instead of images,
and
the “Destroy” option (delete method) no longer works at all.
I am assuming no javascript is being sent to browser, and hence, no joy
in
Mudville…

As mentioned, I’ve been thru the “Asset Pipeline” Rails Guide, but
document
appears written for highly experienced, existing Rails
developers, who need to learn about version changes - ie. from rails 2
and
3 to rails 4. It does not even mention “rake asset:precompile”
anywhere.

Bottom line: What else,. after “rake assets:precompile” do I have to
do,
so that the “rails server … -e production” process
runs correctly using the precompiled assets, and serves up the gosh
darned
javascript to the browser??

If someone wants to enlighten me, great. Otherwise, I will plow thru
this
dreck, until I determine the solution, and will
post a response here. Editorial Note from GEMESYS Ltd: Guys: This
should
not be this difficult to make a baseline trivial app website
actually work as expected, in some sort of sane production mode. N’est
pas?

On Friday, April 15, 2016 at 10:03:20 AM UTC+1, MCL wrote:

When I run the website, of course I get crap. I get the filenames, with
the big hex hash string, shown on the webpage, instead of the
actual image! Arrrgh! Of course there is some secret hipster bit of
trickery, that I need to deploy, to have a return to sanity and
correct operation of my little website. Peradventure, someone might
enlighten me as to WTF this actually is?

Sounds like you have static asset serving turned off - easiest way to
test
this is to go straight to pick a file in public and try to go straight
to
that url,
e.g. if you’ve got public/logo.png then go to http://ip/logo.png. In
production this is usually sensible since you typically have nginx /
apache
handling that side of things.

The setting for this is config.serve_static_files.

Fred