Brody
Joined
Activity
I'm looking for assistance with a mysterious JSON::ParserError
that is popping up while attempting to build a legacy application with minor upgrades (Rails 3.22 -> Rails 5.2.6). It seems to be an issue with the Rails Asset Pipeline but since I've moved on to Webpacker in my other projects it's been very difficult to hunt down the source.
When running rails assets:precompile
locally I have no problem, jQuery is properly binding to elements, etc. The problem arises when I'm pushing the project into Heroku, where I get the following output:
JSON::ParserError: 416: unexpected token at '{"code":"function calculateAdjustedHours(){time_entry_modal=$(\"#timeEntryModal\"),rounded_hours=time_entry_modal.find(\"#txtRoundedHrs\").html(),ot_hours=time_entry_modal.find(\"#txtOvertimeHrs\").html(),adj_hours_fld=time_entry_modal.find(\"#txtAdjHours\"),total_hours_fld=time_entry_modal.find(\"#tdAdjTotal\"),total_hours=accounting.toFixed(parseFloat(rounded_hours)+parseFloat(ot_hours)+parseFloat(adj_hours_fld.val()),2),total_hours_fld.html(total_hours)}function calculateCost(){for(var t=running_total=0;t<50;t++)hours=$(\"#hours-\"+t+\" input\").val(),rate=$(\"#rate-\"+t+\" input\").val(),$.isNumeric(rate)&&$.isNumeric(hours)?(row_total=rate*hours,$(\"#row-total-\"+t).html(accounting.formatMoney(row_total,
The mystery here is that the file appears to be a minified JavaScript file (ending in .js) and not JSON. I've spent the past few hours trying to debug this but getting nowhere:
Running rails assets:precompile
locally produces no difference in git status
config/initializers/assets.rb
contains this line that was previously in config/environments/production.rb
: Rails.application.config.assets.precompile += %w( invoices.js mailer_filters.js ckeditor/config.js )
rails_12factor gem was removed as its documentation says it's not required for Rails 5.
Running rake assets:precompile
from bash on Heroku actually runs without issue, but there is no output regarding any files generated
Before the build problems arose all assets appeared to be loading properly in the client web browser but jQuery events were not binding to elements
app/assets/javascripts/application.js
:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require bootstrap
//= require bootstrap-datepicker
//= require bootstrap-select
//= require data-confirm-modal
//= require scripts
//= require accounting.min
//= require jquery.printPage
//= require overtime_requests
//= require text-overflow
//= require pay_slips
//= require moment.min
//= require momentjs-business
//= require cocoon
//= require jquery_periodical_updater
//= require_tree .