我的供应商文件夹中有一个名为的hammer.js
文件,我想将我的第 3 方 jsvendor/assets/javascripts
和所有自制的东西保存在app/assets/javascripts
.
但是在预编译我的资产时,rails 不会从供应商那里获取我的资产。在我的清单文件中,我指定//= require vendor
了它不起作用,所以我尝试了//= require hammer
并且我//= require hammer.js
从我读到的内容中尝试了这些解决方案似乎对其他人有用。但它根本没有加载它
注意:我bundle exec rake assets:precompile
每次都会检查公共资产,并且每次尝试替代方法时都会渲染页面并查看加载的资源。
编辑:
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require_tree ../../../vendor/assets/javascripts
//= require_tree .
所以我尝试了这个。但它仍然没有加载
在 config/environments/production.rb 我有以下
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
抱歉,这是我第一次在 Rails 中设置 js。