I'm using the jquery fileupload rails gem to load files directly to S3. Everything works fine in localhost, but when deployed to Heroku, the fileupload function is undefined. I've worked around this issue by changing to config.assets.debug = true
in production.rb, but I would like to understand how to get around this so I can disable this setting. Assets are being precompile before deployment.
My application.js looks like this:
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require jquery-fileupload/basic
//= require bootstrap
//= require_self
//= require_directory
//require_tree .
//= require turbolinks
//= require jquery.fixedheadertable.min
Does anyone have any thoughts?
If it's working in development, there are two potential issues:
I'll detail both sets of fixes:
--
Assets
If you're receiving errors with Javascript ("unknown function" etc), you'll likely not have the files/functions available for your app to reference.
This is a common issue when you don't precompile your assets before pushing to production. Using Heroku
automatically precompiles the assets, "standalone" environments don't:
$ rake assets:precompile RAILS_ENV=production
$ git add .
$ git commit -a -m "Precompiled Assets"
$ git push [[your_remote]]
If you're using Capistrano (good luck), I think this has some recipes which includes precompilation, although it's sketchy. Using the above code in your console without pushing to the remote repo will give you the ability to use the precompiled assets in production.
--
S3
The other potentiality is that your production environment can't connect with S3. You've mentioned this not to be the case; for many who want to access S3 in production, you have to set ENV
variables to get it working.
The way to do this changes depending on your production environment; if you're using linux, you can set the variables in etc/environment
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.