好吧,这是我从头开始第一次设置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
上运行时,出现以下错误:
耙子流产了!
不知道如何建立任务'assets:precompile'
是什么原因造成的?
尝试设置config.assets.compile = true
然后重试。 在那之后它应该工作。
干杯!
运行rake assets:precompile --tasks
,未列出预编译任务。
我发现缺少对config/application.rb
的要求:
require 'rails/all'
添加此应用程序后,该应用程序开始预编译并提供资产(实际上,我尝试安装的gem存在一些小错误,我只需要删除配置文件,然后一切正常即可)