JQuery在开发中工作,而不是在Heroku Cedar上制作 [英] JQuery Working in Development, Not Production on Heroku Cedar

查看:86
本文介绍了JQuery在开发中工作,而不是在Heroku Cedar上制作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery在本地开发中为我工作,但在Heroku Cedar中没有生产。我对Rails很陌生,所以我试图以正确的方式学习,而不是仅仅将代码放在视图中。我在服务器日志中看不到任何错误。我在本地编译我的资产:
$ b

bundle exec rake assets:precompile



<然后将整个应用程序推送到Heroku。我已经尝试了几种不同的宝石组合,当前配置:

Gemfile

  source'https://rubygems.org'

gem'rails','3.2.11'
gem'bcrypt-ruby','3.0 .1'
gem'execjs'
gem'jquery-rails'
gem'will_paginate','〜> 3.0.0'
gem'sass-rails','〜> 3.2.3'
gem'bootstrap-sass','〜> 2.2.2.0'
gem'bootstrap-will_paginate','0.0.6'
gemfriendly_id,〜> 4.0.9
gem'twitter'
gem 'devise'
gem'cancan'
gempaperclip,〜> 3.0
gemcocaine,= 0.3.2

group :生产do
gem'pg'
gem'thin'
end
group:development,:test do
gem'sqlite3'
end

#默认情况下,Gems仅用于资产并且不需要
#在生产环境中。
group:assets do
gem'coffee-rails','〜> 3.2.1'
gem'uglifier','> = 1.0.3'
结束

application.js

  // =需要jquery 
// = require jquery_ujs
// =需要引导
// = require_tree。


解决方案

愚蠢的错误,我有一个额外的bootstrap副本我的JavaScript资产文件夹。一旦我删除并重新编译资产,一切都按预期工作。在你的资源中不需要jQuery或bootstrap文件,只需在application.js中包含gems和上面的行,然后在jQuery之后引导。


jQuery is working for me locally in development but not in production on Heroku Cedar. I'm very new to Rails, so I'm trying to learn this the right way rather than just slapping the code into a view. I don't see any errors in the server log. I'm compiling my assets locally with:

bundle exec rake assets:precompile

Then pushing the whole app to Heroku. I've tried several different gem combinations, current configuration:

Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.11'
gem 'bcrypt-ruby', '3.0.1'
gem 'execjs'
gem 'jquery-rails'
gem 'will_paginate', '~> 3.0.0'
gem 'sass-rails',   '~> 3.2.3'
gem 'bootstrap-sass', '~> 2.2.2.0'
gem 'bootstrap-will_paginate', '0.0.6'
gem "friendly_id", "~> 4.0.9"
gem 'twitter'
gem 'devise'
gem 'cancan'
gem "paperclip", "~> 3.0"
gem "cocaine", "= 0.3.2" 

group :production do
  gem 'pg'
  gem 'thin'
end
group :development, :test do
  gem 'sqlite3'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

application.js

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

解决方案

Stupid error, I had an extra copy of bootstrap in my javascript assets folder. Once I removed that and recompiled the assets, everything worked as expected. No need for jQuery or bootstrap files in your assets, just include the gems and the lines above in application.js, bootstrap after jQuery though.

这篇关于JQuery在开发中工作,而不是在Heroku Cedar上制作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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