0

我在我的 Rails 应用程序中使用 Jammit 并且在我的服务器上收到这样的错误:

网络错误:404 未找到 - http://localhost:3000/javascripts/landing/carousel_background.js/javascripts/landing/front.js

javascript 文件位于 public/javascripts/landing 中,我的 assets.yml 如下所示:

embed_assets: off
gzip_assets: off
compress_assets: off

javascripts: 
  ....
  front:
    - public/javascripts/landing/carousel_background.js
    - public/javascripts/landing/front.js
  ...

我的样式表读得很好,但没有我的 js 文件。看起来 js 文件名被连接起来并作为单个文件读取,而不是两个单独的文件。知道会发生什么吗?

编辑:这是我布局的头部的样子:

<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,300' rel='stylesheet' type='text/css' />


<%= render 'shared/title' %>

<%= render 'shared/import_styles' %>
<%= yield :stylesheets %> 
<%= render 'shared/import_ie_styles' %>

<%= include_stylesheets :landing, :media => :all %>

<%= render 'shared/import_scripts' %>
<%= include_javascripts :landing %>

<%= yield :head %>

<%= render 'shared/google_analytics' %>
<%= csrf_meta_tag %>

<%= favicon_link_tag %>
</head>

我的观点有这些 content_for 标签:

<% content_for :head do %>
  <%= include_javascripts :front %>
<% end %>

<% content_for :stylesheets do %>
  <%= include_stylesheets :front, :media => :all %>
<% end %>
4

1 回答 1

1

请记住,Jammits 完成的文件与普通资产不在同一个地方。您不能调用普通的 JavaScript 方法,例如javascript_include_tag,如果您调用include_javascripts(:front)它应该可以正常工作。

于 2012-01-20T17:14:11.217 回答