首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails3.2 config.cache_classes = true结果视图中的空白值

Rails3.2 config.cache_classes = true结果视图中的空白值
EN

Stack Overflow用户
提问于 2014-03-15 01:24:42
回答 1查看 69关注 0票数 0

我有一个提交调整请求的模板(show.html.erb)。此外,在模板中,我有一个表格,其中分解了未决的调整和已完成的调整,这些调整显示了您刚刚提交的调整的相关信息。例如。类型、原因、创建者。

当我在我的环境/development.rb中设置config.cache_classes = true时,除了created at timestamp之外,所有的值都不会显示。类型或原因未显示。如果我设置config.cache_classes = false,所有内容都会出现。我还设置了config.action_view.cache_template_loading = false,但仍然得到相同的结果:空表的值。

我试图让它在config.cache_classes = true的情况下工作,因为在生产环境中,我需要为其他事情打开缓存。

控制器/print_cost_Controler.rb

代码语言:javascript
复制
class PrintCostController < ApplicationController
  def show
    @printcost = PrintCost.find(params[:id])
    @order = Core::Order.find(params[:id])
    authorize! :show, @order
    respond_to do |format|
      format.html { render :show }
    end
  end
end

models/printcost.rb .rb

代码语言:javascript
复制
class PrintCost < ActiveResource::Base
  self.site = ENV["PRINT_COST_URL"]
  @headers  = { 'Authorization' => "Token token=#{ENV['PRINT_COST_TOKEN']}" }
end

show.html.erb

代码语言:javascript
复制
<% if !@printcost.adjustments.empty? %>
  <div class="adjustments_pending">
    <h4 class="printcost">Pending Adjustments</h4>
    <table class="table">
      <tr>
        <th>Requested On</th>
        <th>Reason</th>
        <th>Type</th>
        <th></th>
      </tr>
    <% @printcost.adjustments.each do |adjustment| %>
      <% if adjustment.completed_at == nil %>
        <tr>
          <td><%= DateTime.parse(adjustment.created_at).in_time_zone("Eastern Time (US & Canada)").strftime("%^b-%d-%y %I:%M:%S %P") %></td>
          <td><%= adjustment.explanation %></td>
          <td><%= adjustment.adjustment_type %></td>
          <td><%= link_to 'X', remove_adjustment_path(adjustment.id), :method => :delete, :class => "badge", "data-title" =>"Cancel Request" %></td>
        </tr>
      <% end %>
    <% end %>
  </table>
  </div>
  <div class="adjustments_completed">
    <h4 class="printcost">Completed Adjustments</h4>
    <table class="table">
      <tr>
        <th>Requested On</th>
        <th>Reason</th>
        <th>Type</th>
        <th>Note</th>
      </tr>
      <% @printcost.adjustments.each do |adjustment| %>
        <% if adjustment.completed_at %>
          <tr>
            <td><%= DateTime.parse(adjustment.completed_at).in_time_zone("Eastern Time (US & Canada)").strftime("%^b-%d-%y %I:%M:%S %P") %></td>
            <td><%= adjustment.adjustment_type == "Tax" ? "$#{adjustment.adjustment_cost} - #{adjustment.explanation}" : adjustment.explanation %></td>
            <td><%= adjustment.adjustment_type %></td>
            <td><%= adjustment.note %></td>
          </tr>
        <% end %>
      <% end %>
    </table>
  </div>
<% end %>

你知道为什么会发生这样的事情吗?

EN

回答 1

Stack Overflow用户

发布于 2014-03-18 00:57:53

我发现了问题所在。这是另一个我称之为调整的模型的问题。我不得不给一些东西重新命名。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22411800

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档