当我最近开始使用我的应用程序的移动版本时,我意识到我没有使用为桌面客户端编写的所有 javascript 代码。所以我把这个放进去application.html.erb
<% if mobile_agent? %>
<%= javascript_include_tag "mobile" %>
<%= stylesheet_link_tag "mobile", :media => "all" %>
<% else %>
<%= javascript_include_tag "desktop" %>
<%= stylesheet_link_tag "desktop", :media => "all" %>
<% end %>
在 app > assets > javascripts 我创建了这个结构
- desktop.js
- mobile.js
- desktop/file1.js
- desktop/file2.js
- mobile/file1.js
- mobile/file2.js
- shared/file1.js
- shared/file2.js
在 mobile.js 中:
//= require_tree ./mobile
//= require_tree ./shared
在 desktop.js 中
//= require_tree ./desktop
//= require_tree ./shared
在开发环境中运行良好,但是当我部署到 Heroku 时,它给了我一个错误:
Completed 500 Internal Server Error in 100ms
ActionView::Template::Error (mobile.js isn't precompiled):
8: <meta name="format-detection" content="telephone=no">
11: <%= javascript_include_tag "mobile" %>
9:
12: <%= stylesheet_link_tag "mobile", :media => "all" %>
10: <% if mobile_agent? %>
Parameters: {"community_category"=>"swingdancing", "city"=>"stockholm"}
app/views/layouts/application.html.erb:11:in 78182492067426179_45617280'
13: <% else %>
Completed 500 Internal Server Error in 2ms
app/controllers/communities_controller.rb:20:in `show'
Processing by ErrorsController#show as HTML
14: <%= javascript_include_tag "desktop" %>
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/helpers/rails_helper.rb:142:in Error during failsafe response: mobile.js isn't precompiled
是什么导致了这个错误,我该如何解决?