【问题标题】:How to write complex code inside the XLS file on ruby on rails如何在 ruby​​ on rails 的 XLS 文件中编写复杂的代码
【发布时间】:2015-01-21 10:54:09
【问题描述】:

index.xls.erb

<% @gd = GoodsDelivery.find_all_by_store_location_id(stores.id) %>
<% gd_qty = 0.00 %>
<% for goods_delivery in @gd %>
   <% gdl_qty = goods_delivery.goods_delivery_line_items.where(:product_id => prods.id).where(:customer_bill_id => nil).sum(:quantity) %>
   <% gd_qty = gd_qty + gdl_qty %><% end %>
   <td><%= gd_qty %></td>

由于某些问题,我在 index.xls.erb 文件中有类似这样的代码,但我无法将其移动到控制器中,但在本地服务器中,它运行正常,因为 Heroku 是我的云,它给出如下错误

Error Messege :
Rack::Timeout::RequestTimeoutError: Request ran for longer than 29.989883911185302 seconds.: SELECT SUM("goods_receipt_line_items"."goods_receipt_quantity") AS sum_id FROM "goods_receipt_line_items" WHERE "goods_receipt_line_items"."goods_receipt_id" = 311 AND "goods_receipt_line_items"."product_id" = 133
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1153:in `async_exec' /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1153:in `exec_no_cache' /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter

【问题讨论】:

    标签: ruby-on-rails ruby heroku ruby-on-rails-3.2 heroku-postgres


    【解决方案1】:

    请求超时错误 - 看起来是因为您的数据库速度较慢。尝试在本地运行您的应用并连接到远程数据库 - 我想,您也会收到超时。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多