我正在尝试让 Rails 应用程序脱机工作。该应用程序在联机时似乎可以正常工作。
在 Chrome 中,当服务器运行时,我会在运行应用程序时从 Chrome 控制台看到这一点(部分被剪断)。:
Document was loaded from Application Cache with manifest
http://localhost:3000/application.manifest
Application Cache Checking event
Application Cache Downloading event
...
Application Cache Progress event (5 of 16) http://localhost:3000/assets/todos.css.scss
Application Cache Progress event (6 of 16) http://localhost:3000/assets/application.css
Application Cache Progress event (7 of 16) http://localhost:3000/assets/todos.js.coffee
Application Cache Progress event (8 of 16) http://localhost:3000/assets/jquery.tmpl.js
Application Cache Progress event (9 of 16) http://localhost:3000/assets/jquery.offline.js
...
Application Cache Progress event (11 of 16) http://localhost:3000/assets/jquery.js
...
Application Cache Progress event (13 of 16) http://localhost:3000/assets/json.js
Application Cache Progress event (14 of 16) http://localhost:3000/assets/scaffolds.css.scss
Application Cache Progress event (15 of 16) http://localhost:3000/assets/application.js
Application Cache Progress event (16 of 16)
Application Cache UpdateReady event
但是,离线我看到了这个(同样,有些被剪断了)。请注意,这些GET
行是加载错误。:
Document was loaded from Application Cache with manifest http://localhost:3000/application.manifest
Application Cache Checking event
GET http://localhost:3000/assets/application.css?body=1 todos:5
GET http://localhost:3000/assets/scaffolds.css?body=1 todos:6
GET http://localhost:3000/assets/todos.css?body=1 todos:7
GET http://localhost:3000/assets/jquery.js?body=1 todos:8
GET http://localhost:3000/assets/jquery_ujs.js?body=1 todos:8
GET http://localhost:3000/assets/jquery.offline.js?body=1 todos:8
GET http://localhost:3000/assets/jquery.tmpl.js?body=1 todos:8
GET http://localhost:3000/assets/json.js?body=1 todos:8
GET http://localhost:3000/assets/offline.js?body=1 todos:8
GET http://localhost:3000/assets/todos.js?body=1 todos:8
GET http://localhost:3000/assets/application.js?body=1 todos:8
Application Cache Error event: Manifest fetch failed (-1) http://localhost:3000/application.manifest
特别是,我注意到?body=1
离线时附加到文件名。
环境:
- 导轨:3.2.8
- 红宝石 1.9.3p194
- WEBrick:1.3.1
- MySQL:5.5.28 MySQL 社区服务器
- 铬:版本 22.0.1229.94 m
- 操作系统:Windows 7 企业版 6.1(内部版本 7601:Service Pack 1)
宝石(我认为相关的宝石):
- jquery-rails (2.1.3)
- json (1.7.5, 1.5.4)
- 机架离线(0.6.4)
- 链轮 (2.1.3)
应用清单:
CACHE MANIFEST
# ef05db1f746b226b3eb8b3673d65d3585eb8a9e1e35f79a6fc9d90693ff9a569
404.html
422.html
500.html
index.html
assets/application.js
assets/jquery.js
assets/jquery.offline.js
assets/jquery.tmpl.js
assets/json.js
assets/todos.js.coffee
assets/application.css
assets/scaffolds.css.scss
assets/todos.css.scss
NETWORK:
/
application.html.erb:
<!DOCTYPE html>
<html manifest="/application.manifest">
<head>
<title>TestOffsite</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
todos_controller.erb(剪断):
class TodosController < ApplicationController
# GET /todos
# GET /todos.json
respond_to :html, :json
def index
@todos = Todo.all
respond_with(@todos)
#respond_to do |format|
# format.html # index.html.erb
# format.json { render json: @todos }
#end
end
...
manifest.yml 的内容:
---
rails.png: rails-be8732dac73d845ac5b142c8fb5f9fb0.png
application.js: application-39fb9cbdc400e6885a41059ea60f3851.js
application.css: application-0149f820dbdd285aa65e241569d8c256.css
任何帮助深表感谢。