【问题标题】:active_scaffold w/ Rails 3.2 gives no visible response for search, edit, new actions etc带有 Rails 3.2 的 active_scaffold 对搜索、编辑、新操作等没有可见的响应
【发布时间】:2013-03-15 17:19:37
【问题描述】:

我添加了几个带有活动脚手架的模型和控制器。但是,每当我单击任何操作(例如新建、编辑、搜索、显示等)时,浏览器中都看不到任何内容。如日志所示,服务器似乎正在响应它:

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">
    - &nbsp;
  </dd>
  <dt>Genes</dt>
    <dd class="genes-view">
    - &nbsp;
  </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>

我怀疑问题有两个问题:

  1. 响应头中提到了js,但是响应体是HTML。虽然我认为 AJAX 可能会发生这种情况。
  2. 我在我的资产(application.js 标头)中使用 jquery,而 active_scaffold 可能正在尝试使用原型。我该如何检查?请注意,在 Rails 3.2 中,安装 active_scaffold gem 时没有提及原型或 jquery:https://github.com/activescaffold/active_scaffold/wiki/Getting-Started

【问题讨论】:

    标签: jquery ruby-on-rails ruby-on-rails-3.2 prototypejs activescaffold


    【解决方案1】:

    页面上的数据有变化吗?我认为activescaffold 正在使用 ajax 重新渲染页面的某些部分,因此您不会看到漏洞页面发生变化。如果屏幕上没有任何不同,那么它看起来就像什么都没发生。

    答案:使用 git master gem 'active_scaffold', :git =&gt; 'git://github.com/activescaffold/active_scaffold.git' 详情见下文

    【讨论】:

    • 页面上没有任何变化。我了解整个页面可能不会改变,但不会有任何改变。
    • 所以我可能没有正确地说明这一点,但看起来你正在对 Organism 执行 #show 更改了 Organism 的任何属性。您可以进入rails console 并将新的Gene 添加到现有的Organism
    • 我从控制台添加了一些数据。似乎如果我右键单击编辑、显示、新链接并选择在新选项卡中打开,我可以看到发送的表单,但页面没有更新页面中的响应。我认为它可能是事件处理程序。但是 jquery 和 active_scaffold.js 都包含在内。
    • 如果您使用的是ChromeSafari,请打开开发者控制台,看看您是否遇到了javascript 错误。
    • 我收到TypeError: jQuery(...).live is not a function
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多