资产"application.js"在资产管道中不存在

编程入门 行业动态 更新时间:2024-10-27 17:20:59
本文介绍了资产"application.js"在资产管道中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是 Ruby 和 ROR 框架中的新手.我尝试使用JQuery创建Web应用程序.我的步骤是:

I'm new in Ruby and in ROR framework. I try to create web app with JQuery. My steps are:

  • 添加了gem'jquery-rails'并从命令行执行了捆绑安装命令
  • 将字符串 //= require jquery2 添加到 application.js 文件
  • 现在,我尝试将文件包含到页面中.然后在 application.html.erb 文件中添加了段字符串 <%= javascript_include_tag "application" %>
  • Added gem 'jquery-rails' and executed bundle install command from command line
  • String //= require jquery2 added into application.js file
  • Now I try include file into page. And I added in section string <%= javascript_include_tag "application" %> into application.html.erb file
  • 当我尝试在浏览器中查看页面时,看到错误消息:

    when I try to see page in browser I see error with message:

    Sprockets::Rails::Helper::AssetNotFound in LandingPage#index The asset "application.js" is not present in the asset pipeline. <%= javascript_include_tag "application" %>

    我做错了什么?我在Google上搜索了此错误,但没有找到任何好的解释.

    What I doing wrong? I googled about this error, but I didn't found anything good explained.

    推荐答案

    首先尝试重新启动服务器,通常不需要在资产中包含application.js文件.如果不起作用,则

    first of all try to restart your server, generally there is no need to include application.js file in assets. if it doesn't work then

    在您的 config / initializer / assets.rb 文件中添加以下内容:

    add below in your config / initializer / assets.rb file:

    Rails.application.config.assets.precompile += %w(application.js)

    注意:添加资产文件后,请不要忘记重启服务器.如果您在Inilalizers中进行了任何更改,则必须重新启动服务器才能看到效果.

    Note: after adding in your assets file, don't forget to restart your server. If you do any changes in Inilalizers, you have to restart the server to see the effects.

    更多推荐

    资产"application.js"在资产管道中不存在

    本文发布于:2023-07-08 01:06:04,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1070175.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:资产   中不   管道   application   quot

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!