问题
I have an app and I use there the autocomplete gem. It works me great on localhost. But when I deploy this app to Heroku, the autocomplete plugin doesn't works me. No errors in Firebug, just nothing.
Does anyone an idea, where could be a problem?
This is how look my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.2'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem "rvm", "~> 1.9.2"
gem 'authlogic'
gem "rake", "0.8.7"
gem 'json'
gem "declarative_authorization", "~> 0.5.3"
gem "ancestry", "~> 1.2.4"
gem "taps", "~> 0.3.23"
gem "paperclip", "~> 2.4.5"
gem 'aws-s3'
gem "awesome_print", "~> 1.0.1"
gem 'actionmailer'
gem 'wkhtmltopdf-binary'
gem 'rails3-jquery-autocomplete'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5.rc.2'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
gem 'pg'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
回答1:
For anyone coming here from Google - I searched and searched - finally - in my case the answer turned out the be the include directive in app/assets/application.js:
// 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_ujs**
//= require excanvas.min
//= require bootstrap.min
I added the ** fyi
When you take OUT that line, because you have jquery-rails gem installed (you do have jquery-rails installed right?) then run:
RAILS_ENV=production bundle exec rake assets:precompile:all
At your shell in your Rails app's root directory (I'm spelling everything out here cause a lot of times people don't explicitly state everything in their comments!)
You shouldn't get any errors - it's that :all at the end that was revealing the jquery / jquery_ujs errors.
If you just type:
bundle exec rake assets:precompile
You probably won't get any errors - but jquery won't work either (this is the part that tripped me out).
When I found another comment on SO that said to add :all and it would reveal jquery erros - viola! - it told me stuff wasn't right.
So finally removing the jquery_ujs (which was documented as DON'T REMOVE THIS ON PAIN OF DEATH in other places...) and compiling and then running unicorn as though I'm in production - it works great.
The bonus of course is now that you have your assets compiled you can throw that folder up on Amazon S3, open a CloudFront account, use something like asset_sync gem - and reduce the load even more on Heroku's dynos.
BALLER
回答2:
In my case i had to delete this plugin from my gem file gem 'sprockets_better_errors'
来源:https://stackoverflow.com/questions/8675122/jquery-ui-doesnt-work-on-heroku-but-on-localhost-yes