我添加了几个带有活动脚手架的模型和控制器。但是,每当我单击任何操作(例如新建、编辑、搜索、显示等)时,浏览器中都看不到任何内容。似乎服务器正在响应它,因为日志显示:
Started GET "/organisms/1" for 127.0.0.1 at 2013-03-15 12:55:35 -0400
Processing by OrganismsController#show as JS
Parameters: {"id"=>"1"}
Organism Load (0.4ms) SELECT "organisms".* FROM "organisms" WHERE "organisms"."id" = $1 LIMIT 1 [["id", "1"]]
(0.4ms) SELECT COUNT(*) FROM "genes" WHERE "genes"."organism_id" = 1
Rendered /opt/local/lib/ruby1.9/gems/1.9.1/gems/active_scaffold-3.2.19/frontends/default/views/_show_columns.html.erb (2.9ms)
Rendered /opt/local/lib/ruby1.9/gems/1.9.1/gems/active_scaffold-3.2.19/frontends/default/views/_show.html.erb (15.4ms)
Completed 200 OK in 32ms (Views: 26.0ms | ActiveRecord: 0.9ms)
但是浏览器窗口中没有任何变化。Firebug 'Net' 日志显示响应标头:
Cache-Control max-age=0, private, must-revalidate Connection close
Content-Type text/javascript; charset=utf-8
Etag "c08465bfa6a67a8fb4f88964513a6b23" Server thin 1.5.0 codename
Knife X-Request-Id 6ee347aa85988460733ffbda65ea12ee X-Runtime 0.036693
X-UA-Compatible IE=Edge
对我来说,响应看起来像 html:
<h4></h4>
<dl>
<dt>Name</dt>
<dd class="name-view">
-
</dd>
<dt>Genes</dt>
<dd class="genes-view">
-
</dd>
</dl>
<p class="form-footer">
<a href="/organisms" class="as_cancel" data-remote="true">Close</a>
<img alt="loading indicator" class="loading-indicator" id="as_organisms-create-1-loading-indicator" src="/assets/active_scaffold/indicator.gif" style="visibility:hidden;" />
</p>
我怀疑问题有两个问题:
- 响应头中提到了 js,但响应体是 HTML。尽管我认为 AJAX 可能会发生这种情况。
- 我在我的资产(application.js 标头)中使用 jquery,而 active_scaffold 可能正在尝试使用原型。我该如何检查?请注意,在 Rails 3.2 中,安装 active_scaffold gem 时没有提及原型或 jquery:https ://github.com/activescaffold/active_scaffold/wiki/Getting-Started