2010-09-05 92 views
0

在一個給定的html.erb文件,我有如何防止在Rails中打印封閉的返回值?

<%= render "steps_list", :post => @post%> 

_steps_list.html.erb,我有

<%= @post.step_names.each do |step| %> 
    Step: <%= "#{step}" %> 
<% end %> 

這有一個例外效果很好。每一步都按照我的意願打印出來,但整個數組也會在最後打印出來。

Step: Rinse Step: Lather Step: Repeat RinseLatherRepeat

我懷疑整個陣列在端打印出來,因爲封閉件返回時,它的結束執行該陣列。如何禁止打印數組或封閉的返回值?

回答

2

改爲使用它。

<% @post.step_names.each do |step| %> 
    Step: <%= "#{step}" %> 
<% end %> 

<%= ### %>表示「打印此輸出」。

+0

D'oh。不用說,新手在這裏。謝謝。 :) – Sanjay 2010-09-06 00:00:20

+0

不客氣。請享用。 – jdl 2010-09-06 00:14:38