嗯,这是我第一次从头开始设置Rails应用程序,而我刚创建了第一个视图。
当我运行服务器时,在尝试加载application.js
文件时出现404 Not Found错误。
布局
<html>
<head>
<%= yield :head %>
</head>
<body>
<h1>If you're not and Admin you shouldn't be here!</h1>
<%= yield %>
<%= javascript_include_tag 'application' %>
<% yield :script %>
<script>
$(function(){
alert('Hey')
})
</script>
</body>
</html>
的application.js
//= require jquery
环境/ development.rb
...
config.assets.debug = false
config.assets.compile = false
config.assets.digest = true
...
当我在终端rake assets:precompile
上运行时,我收到此错误:
rake aborted!
不知道如何构建任务&#39;资产:预编译&#39;
造成这种情况的原因是什么?
答案 0 :(得分:2)
答案 1 :(得分:0)
尝试设置config.assets.compile = true
然后重试。它应该在那之后工作。
干杯!
答案 2 :(得分:0)
运行rake assets:precompile --tasks
后,未列出预编译任务。
我发现config/application.rb
上的要求丢失了:
require 'rails/all'
添加此应用程序后,应用程序开始预编译并提供资源(实际上我尝试安装的gems存在轻微错误,我只需删除配置文件,然后一切正常)