【问题标题】:Rails Comments on View if-end statement screw up rendering on Linux/Apache/FastCGIRails 对 View if-end 语句的评论搞砸了 Linux/Apache/FastCGI 上的渲染
【发布时间】:2009-10-17 16:36:42
【问题描述】:

以下代码可以在我的 Windows 开发环境下工作,但不能在我的生产 Linux/Apache2/FastCGI 环境下工作。

在我看来 rhtml 文件:

<td id='first_column' class='column'>
       <% content_for :head do #DO NOT CACHE THIS content for : HEAD %>
            <%= stylesheet_link_tag('live_tree') %>
            <%= javascript_include_tag "live_tree" %>
       <%  end #content_for %>
       <div  id='contentpanel_13B'>
              <div id='category_howtos_container'>
                    <%= render :partial => 'howtos_for_category'%>
              </div>
       </div>
       <% cache('category_gadget'+I18n.locale.to_s) do %>
           <div class='main_container gadget' id='categories_container'> 
               <%= render :partial => 'categories' %> 
           </div>
       <% end %>
</td>

这段代码在linux下没有渲染div contentpanel_13B...我将问题隔离到这一行的评论:

             <%  end #content_for %>

我在 Rails 2.3.2 和 2.3.3 下尝试过,但没有成功……有什么提示吗?

【问题讨论】:

    标签: ruby-on-rails windows linux apache2 comments


    【解决方案1】:

    可能是注释阻止了 '%>' 被解析

    尝试将评论放在单独的行

    
    <%  end 
        #content_for 
    %>
    

    【讨论】:

    • 是的,它有效,我也相信这是原因,但是,我不想更改我所有的代码 cmets 以在我的 Linux 堆栈上工作:-S...我不明白为什么它不起作用。
    • 不知道为什么你会得到错误(没有比跨环境不一致的错误更糟糕的了),但另一方面 - 在
    【解决方案2】:

    我遇到了与&lt;% cache(...) do %&gt; 相同的问题,一些缓存的html &lt;% end # some comment %&gt; 块并将评论放在自己的行上对我不起作用。我必须这样做:&lt;% cache do(...) %&gt; 一些缓存的 html % end %&gt;&lt;% some comment %&gt;

    【讨论】:

      猜你喜欢
      • 2012-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-27
      • 1970-01-01
      • 2021-06-12
      • 1970-01-01
      相关资源
      最近更新 更多