为什么在Rails 3中这个erb行为发生了变化?

Jos*_*hua 6 ruby-on-rails

我正在将Rails 2.8应用程序移植到Rails 3.大多数东西现在正在工作,并且正在慢慢解决问题.我发现的一种行为令人困惑,我想了解幕后发生了什么变化.以下代码段在2.x中有效,但在3.0中失败:

<% if @apps.nil? || @apps.empty? %>
  No rated applications.
<% else 
  ratingshidden = false
    @apps.each { |app| %>
 display app stuff etc....
Run Code Online (Sandbox Code Playgroud)

要使它在3中工作,我必须改变如下:

<% if @apps.nil? || @apps.empty? %>
  No rated applications.
<% else %>
<%
  ratingshidden = false
    @apps.each { |app| %>
 display app stuff etc....
Run Code Online (Sandbox Code Playgroud)

rails中有什么变化要求更新语法?

Adi*_*ghi 7

我很乐意申请赏金并改写它,但我认为您正在寻找的文章是http://timeless.judofyr.net/block-helpers-in-rails3


nuc*_*ich 0

这个Railscast 解释了 Rails 3 中 erb 块的变化以及它们的制作原因。