jQuery-ui在Heroku上不起作用,但在localhost上是 [英] Jquery-ui doesn't work on Heroku, but on localhost yes

查看:138
本文介绍了jQuery-ui在Heroku上不起作用,但在localhost上是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,并且在其中使用了autocomplete gem.它在localhost上对我很有用.但是,当我将此应用程序部署到Heroku时,autocomplete插件对我不起作用. Firebug中没有错误,只有错误.

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.

有人在想什么,哪里可能有问题? 这是我的Gemfile:

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'

推荐答案

对于来自Google的任何人-我进行了搜索并进行了搜索-最终-就我而言,答案竟然是include指令在app/assets/application.js中:

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

我添加了** fyi

I added the ** fyi

当您退出该行时,因为您已经安装了jquery-rails gem(您确实安装了jquery-rails吗?),然后运行:

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

在Rails应用程序根目录中的外壳程序中(我在这里拼写所有内容的原因很多时候人们没有在评论中明确声明所有内容!)

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!)

您应该不会有任何错误-就是最后的所有内容都揭示了jquery/jquery_ujs错误.

You shouldn't get any errors - it's that :all at the end that was revealing the jquery / jquery_ujs errors.

如果您只输入:

bundle exec rake assets:precompile

您可能不会收到任何错误-但jquery也不起作用(这是让我绊倒的部分).

You probably won't get any errors - but jquery won't work either (this is the part that tripped me out).

当我在SO上找到另一条评论时说::all,它将显示jquery错误-中提琴! -告诉我东西不对.

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.

因此,最后删除了jquery_ujs(在其他地方,它被记录为不要在死神上移除它……"),然后编译并像我在生产中一样运行独角兽-效果很好.

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.

当然,现在的好处是,您已经对资产进行了编译,可以将该文件夹放在Amazon S3上,开设一个CloudFront帐户,使用诸如asset_sync gem之类的东西-并进一步减轻Heroku测功机的负担.

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

这篇关于jQuery-ui在Heroku上不起作用,但在localhost上是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆