繁体   English   中英

Rails controller.js.coffee没有显示

[英]Rails controller.js.coffee not showing up

我刚开始使用Rails。

在资产javascript内部,有一个文件(welcome.js.coffee)内容为

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

我把这个功能放在下面

$(document).ready ->
    alert "Hello World"

如果我放了application.js文件,

//= require welcome

显示警报,否则显示。

我正在跳过某些内容,或者即使welcome.js.coffee文件说该逻辑将自动在application.js中可用,我仍然必须手动要求该文件吗?

您的application.js应该列出

//= require_tree .

作为其中的一行,这需要该文件所在目录树中的所有其他文件。如果缺少或需要此行,则必须将其添加回去,否则就需要专门的文件(与welcome )上班。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM