【发布时间】:2015-09-11 06:13:26
【问题描述】:
我正在使用 rails v4.2.4。我尝试使用命令创建一个测试应用程序
rails new app
尽管我可以在 Gemfile 中看到 jquery 引用(也存在于 application.js 中),并且我也运行了 bundle install,但是,vendor/assets/javascript 目录是空的并且不包含 JS 文件.我也已经运行了 bundle install 。我应该手动添加它们还是我错过了在 Rails 项目中为我提取这些文件的命令?
app/assets/javascripts 中的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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
【问题讨论】:
-
您希望 JS 文件如何呈现在
vendor/assets/javascripts目录中?签入app/assets/javascripts目录 -
该目录有一个引用 jquery 的 application.js。我的问题是:我需要运行命令将这些文件拉入项目还是应该在我调用 rails new app 时添加它们?
标签: javascript jquery ruby-on-rails ruby-on-rails-4