0

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 .
4

2 回答 2

1

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

于 2013-02-08T02:50:33.327 回答
0

就我而言,我只是运行这些命令:

  • heroku 运行 gem 清理
  • rake 资产:预编译(语言环境)
  • git push heroku master 在这之后它在rails 5中对我有用
于 2017-07-03T16:22:09.457 回答