Rails,default.js为空,并且未加载jquery和jquery_ujs

我正在使用导轨导轨在轨道上练习ruby。 在5.13删除文章部分中,他们将展示如何创建删除(销毁)function。 我正确地执行了步骤,但未显示删除确认对话框,并且文章未被删除。 当我检查chrome开发人员工具时,不包括“jquery”和“jquery_ujs”,并且“default.js”为空。 我正在Windows 7上的rails上运行ruby。

这是我的文章控制器,

class ArticlesController < ApplicationController def index @articles = Article.all end def show @article = Article.find(params[:id]) end def new @article = Article.new end def edit @article = Article.find(params[:id]) end def create @article = Article.new(article_params) if @article.save redirect_to @article else render 'new' end end def update @article = Article.find(params[:id]) if @article.update(article_params) redirect_to @article else render 'edit' end end def destroy @article = Article.find(params[:id]) @article.destroy redirect_to articles_path end private def article_params params.require(:article).permit(:title, :text) end end 

这是视图(app / views / articles / index.html.erb)

 

Listing Articles

Title Text

本教程的这一部分用于创建此删除/销毁function。

编辑 :我没有编辑任何js文件,因为所说的教程此时没有说要改变任何js文件,但正如有人在评论中要求所以我添加了js文件,这就是应用程序的方式。 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 . 

编辑2 🙁在@ NitishParkar评论之后编辑)
当我遵循Rails指南时,当我到达这一点时 ,文章控制器的CRUD部分已经完成。 这就是列出的文章以及“显示”,“编辑”和“破坏”的链接。

上市文章

当我检查第一个destroy(删除)链接的源时,它看起来像这样: Destroy Destroy

但是当我点击它时,它没有显示任何确认对话框,浏览器跳转到http://localhost:3000https://stackoverflow.com/articles/1 ,文章没有被删除。

你身边的一切都很好。 你说你在Windows 7上,当我因某些原因需要在Windows上运行rails时,我也遇到过这个问题。 比我在这里找到了一个帮助我摆脱这个问题的答案。 实际上,coffee-script-source,v 1.9.x会在windows上出现问题,所以如果你使用v 1.8.0,这个问题就会消失。

在你的Gemfile gem 'coffee-script-source', '1.8.0'包含gem 'coffee-script-source', '1.8.0'

而不是运行bundle update coffee-script-source