1

I previously found help here for how to hide and show form fields based on whether a radio button in the same form is set to true or false.

This works fine in my development environment.

I just pushed to heroku and have checked the production version. Nothing happens when I select the true button in the form field that is supposed to reveal the hidden fields.

Others who have had similar issues describe this as a problem attributable to not precompiling assets.

Here is my setup.

application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require jquery-fileupload/vendor/jquery.ui.widget
//= require jquery-fileupload/jquery.iframe-transport
//= require jquery-fileupload/jquery.fileupload
//= require bootstrap-sprockets
//= require moment
//= require bootstrap-datetimepicker
//= require pickers
//= require underscore
// require gmaps/google
//= require markerclusterer
//= require cocoon
//= require_tree .

I expect that require_tree will pick up all of the files saved in my app/javascripts directory.

The js that solved the initial problem I posted about in my linked post is saved in app/javascripts/stances/commercial.js.

production.js

# Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = true

  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

initializers/assets.rb

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )

When I push to heroku, I can see from the log that the precompile does happen:

Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Asset precompilation completed (3.51s)

The heroku docs say that I shouldn't need to manually precompile assets because it's done on deployment. That makes sense because the above log shows that it is happening. Is there something else I need to be doing to make heroku pick up my js files in production?

This post suggests that Heroku doesnt precompile if there is a public/assets/manifest.yml file in the repo. There is no such file in my application, so i'm expecting that heroku is compiling my assets. It looks from the log (copied above) that it has - so I'm confused about whether I'm supposed to precompile assets before pushing to production or rely on the process that Heroku is supposed to be doing.

Community
  • 1
  • 1
Mel
  • 2,481
  • 26
  • 113
  • 273
  • Can you tell if the `stances/commercial.js` file is getting included in the compiled JS on production? Are there any JS errors in the browser console? – Jen Nov 27 '16 at 02:04
  • There are no js errors in the browser console. Where can I look to see if the files are getting compiled on production? I copied the bit of the log that shows where heroku is running precompile on the assets – Mel Nov 27 '16 at 02:12
  • I would just check in the browser, find your application.js file in the network tab or sources tab, and check that it contains what you expect. – Jen Nov 27 '16 at 02:15
  • I can see a file referenced as: assets/application-a43f34d1c3c8178549c0365cf03acdfc31e05451976bdd9c08c1a50821afef83.js but I can't find a way to see what is contained in that file. – Mel Nov 27 '16 at 22:12
  • Right click, view source, find the file name, click the link. – Jen Nov 27 '16 at 23:50
  • it's just a huge long page of text. I can't ready what it says in any logical fashion. There are no file names in it. – Mel Nov 28 '16 at 00:01
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/129176/discussion-between-guiniveretoo-and-mel). – Jen Nov 28 '16 at 00:03

0 Answers0