Javascript不能在Ruby on Rails部署模式下工作
Javascript not working in Ruby on Rails Deployment mode
当我的Ruby on Rails项目处于部署模式时,我无法获得任何javascript运行。我有一个js在vendor/assets/javascript/theme/index-slider.js。它在这个文件中有一个警告来测试javascript是否正常工作:
alert('TestTestTest');
当我在开发模式下运行项目时,所有javascript都正常运行。此外,如果我将<script>alert("Testme");</script>
添加到我的index.html.erb文件中,该javascript将在生产模式下运行。
我一直在运行rake assets:precompile
和RAILS_ENV=production rake assets:precompile
时进行更改以及重新启动服务器
如何让Javascript在生产模式下运行?(另外,我对Ruby on Rails相当陌生,所以我不确定我应该包括哪些文件/信息来帮助。)谢谢。
application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require bootstrap/bootstrap
//= require theme/bootstrap.min
//= require theme/flexslider
//= require theme/index-slider
//= require theme/jquery.countdown.min
//= require theme/jquery.isotope.min
//= require theme/theme
//= require_tree .
我发现问题在于application.js文件。我已经添加了bootstrap到我的项目手工以及bootstrap主题。我发现,无论出于何种原因,//= require bootstrap/bootstrap行不应该包含在我选择的主题之上。
您还需要为您的产品编译资产
rake assets:precompile RAILS_ENV=production
相关文章:
- Javascript,访问一个主要对象模块模式中的每个对象
- 是否有任何snippet或jQuery插件可以列出easylist.txt模式匹配的DOM中的所有元素
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 同位素库错误:未捕获错误无布局模式包装生产线8
- 在DOM中查找一个模式并替换它's的内容使用jquery
- 如何缩短MongoDB ObjectId并在Mongoose模式中使用它
- D3.js模式不适用于弧形或圆环图
- Webdriver.io pageObject模式-通过传递参数来定义元素选择器
- 模块模式和这个
- 带有let的JS/EECMAScript6私有字段的模式
- 我是否可以检测到javascript正在被卸载(作为调试模式)
- 执行动态模式弹出
- 注意:wp_enqueue_script调用不正确.在 Wordpress 调试模式下
- AngularJS ui路由器html5模式中断路由
- 使用CI和CodeDeploy对node.js应用程序进行连续部署
- 包含圆括号的JavaScript Regex模式
- 显示模块模式在Knockout中设置模型的新实例
- Node.js使用Series函数(模式?)实现流控制时出现意外结果
- 部署时使用npm包时发生Meteor错误
- Javascript不能在Ruby on Rails部署模式下工作