Rails JavaScript视图无法在生产中使用 [英] Rails JavaScript views not working in production

查看:99
本文介绍了Rails JavaScript视图无法在生产中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Rails应用程序遇到了无法解释的问题。我在应用程序的所有部分都使用了很多JavaScript。在开发过程中一切正常,但在生产中似乎我的javascript 视图中的代码没有被执行。

I'm having an unexplainable issue with my Rails app. I'm using a lot of JavaScript in all parts of the app. In development everything is working just fine, but in production it seems that the code in my javascript views is not executed.

这个特别奇怪因为页面上的所有其他JavaScript工作得很好。 JavaScript工作的自定义标签。甚至我的定制日历也按预期工作。唯一不起作用的是触发以.js.coffee结尾的视图的远程链接。

This is particularly odd because all other JavaScript on the page works great. Custom tabs with JavaScript work. Even my custom made calendar works as expected. The only things that do not work are remote links which trigger views ending with .js.coffee.

我的webkit检查器在单击远程链接时返回此信息:
http://cl.ly/Ihyf

My webkit inspector returns this when clicking a remote link: http://cl.ly/Ihyf

但是,当查看该请求的响应选项卡时,它没有显示任何内容:
http://cl.ly/Ihxs

However, when looking at the response tab of that request it shows me nothing: http://cl.ly/Ihxs

此外,控制台不会显示任何错误。好像我的new.js.coffee只是空的。

Furthermore, the console does not show any errors. It's as if my new.js.coffee is just empty.

被调用的视图包含一些简单的JavaScript来显示模态:

The view that is being called contains some simple JavaScript to show a modal:

$('#modal_container').html("<%=j render 'form' %>")
$('#modal_container').modal()

在开发模式下,所有视图都正确加载。我也运行了rake:assets:多次预编译,但这似乎没有帮助。

In development mode, all views load properly. I also ran rake:assets:precompile multiple times, but that didn't seem to help.

推荐答案

你应该移动 coffee-rails 来自:assets 组的宝石到主要组。

You should move coffee-rails gem from the :assets group to the main group.

这篇关于Rails JavaScript视图无法在生产中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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