我一直在互联网上寻找并尝试不同的事情好几天(包括许多类似的问题),但我仍然没有找到答案。
我在heroku上托管并使用cloud9进行开发(在rails中)。在开发上一切都很好。在生产中似乎正常的javascript工作,但jquery代码不起作用。我无法弄清楚发生了什么。我将在下面发布一些可能有用的代码。我相信这可能是一个简单的修复,我只是忽略了。
我有预编译资产,然后将它们添加到git。当我这样做时,javascript工作和更新,它只是jquery根本不工作。
我不知道它是否与bootstrap有任何关系。
真的,我非常感谢任何帮助或指示。
以下是javascript控制台中的错误: Javascript console errors
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require_tree .
/* global $ */
这是我的production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
# `config/secrets.yml.key`.
config.read_encrypted_secrets = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "project_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
宝石文件
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
gem 'sqlite3', '1.3.13'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'rails_12factor', group: :production
gem 'devise'
gem "font-awesome-rails"
gem 'font-awesome-sass'
gem 'omniauth-google-oauth2'
gem 'paperclip', '~> 4.1'
gem 'jquery-rails'
gem 'bootstrap', '~> 4.1.1'
group :production do
gem 'pg', '0.20.0'
end
答案 0 :(得分:0)
您错误地指出未定义Popper
。查看bootstrap-rubygem
docs reavals,在您需要bootstrap-sprockets
之前必须要求使用popper:
//= require popper
//= require bootstrap-sprockets
我认为这是你的问题。如果您没有定义依赖关系,那么assets:precompile
不会收集所有需要的文件,而您的css和js在生产中也不起作用。
答案 1 :(得分:0)
在您的assets / javascript / application.js中 代码应如下所示:
Sub Range_Split_And_Transpose()
Const kItem As String = "New Entry"
Dim iNewEntry As Integer, iRows As Integer
Dim wsSrc As Worksheet, wsTrg As Worksheet
Dim rgData As Range, rgArea As Range
Dim aRcrd As Variant, lRcrds As Long, bItms As Byte
iNewEntry = MsgBox( _
"Do you want to include the ""New Entry"" line?", _
vbApplicationModal + vbQuestion + vbYesNoCancel + vbDefaultButton2, _
"Range Split & Transpose")
If iNewEntry = vbCancel Then Exit Sub
iRows = MsgBox( _
"Do you want to post the output as a List (by rows)?", _
vbApplicationModal + vbQuestion + vbYesNoCancel + vbDefaultButton1, _
"Range Split & Transpose")
If iRows = vbCancel Then Exit Sub
Rem Set Objects
With ThisWorkbook
Set wsSrc = .Sheets("DATA")
.Worksheets.Add After:=.Sheets(.Sheets.Count) 'Adds Output Worksheet
Set wsTrg = .Worksheets(.Worksheets.Count)
End With
Rem Set Range Data
With wsSrc
If Not (.AutoFilter Is Nothing) Then .Cells(1).AutoFilter 'Clears AutoFilter
Set rgData = .Cells(1).Resize(.Cells(.Rows.Count, 1).End(xlUp).Row, 1)
End With
Rem Split Range Into Areas - One Area per Complaint
With rgData
.AutoFilter Field:=1, Criteria1:="<>" & kItem
If .Cells(1).Value2 = kItem Then .Rows(1).EntireRow.Hidden = True
Set rgData = .SpecialCells(xlCellTypeVisible)
.Rows(1).EntireRow.Hidden = False
.Cells(1).AutoFilter
End With
Rem Post New Entry Line
bItms = 1
If iNewEntry = vbYes Then
bItms = 2
With wsTrg.Cells(1, 1)
If iRows = vbYes Then
.Resize(rgData.Areas.Count, 1).Value = kItem
Else
.Resize(1, rgData.Areas.Count).Value = kItem
End If: End With: End If
Rem Post Output
lRcrds = 0
For Each rgArea In rgData.Areas
Rem Record to Array
aRcrd = WorksheetFunction.Transpose(rgArea.Value2)
If iRows = vbNo Then aRcrd = rgArea.Value2
Rem Post Record
lRcrds = 1 + lRcrds
If iRows = vbYes Then
wsTrg.Cells(lRcrds, bItms).Resize(1, rgArea.Rows.Count).Value2 = aRcrd
Else
wsTrg.Cells(bItms, lRcrds).Resize(rgArea.Rows.Count, 1).Value2 = aRcrd
End If: Next
wsTrg.UsedRange.Columns.AutoFit
End Sub