2010-05-29 85 views
0

我正在通過適應模板我正在工作,我已經給出了基本上是待售產品的列表。我想將其從一個自上而下的列表更改爲一個表格佈局。 我想要的東西落得如下 -紅寶石erb模板 - 嘗試更改佈局 - 獲取錯誤

<div id= 'ladiesproducts'> 
<% ladies_products = hosting_products.find_all do 
|product| 
product.name.match("ladies") 
end %> 
<table><tbody> 
<% [ladies_products].each do | slice | %> 
<tr> 
<% slice.each do | product | %> 
<td> 
<h4><%= product.name.html %></h4> 
<p><%= product.description %></p> 
<% other parts go here %> 
</td> 
<% end %> 
</tr> 
<% end %> 
</tbody></table> 
</div> 

這工作得很好,我想實現的佈局。 我遇到的問題是當我將其他部分粘貼回<%這裏%>部分代碼。 我在頁面上收到一條內部錯誤消息。 我對Ruby完全陌生,所以我真的很笨拙。我有一種預感,我忽略了可能非常簡單的事情。 的<% other parts go here %>代碼如下:

<input type='hidden' name='base_renewal_period-<%= i %>' value="<%= 
product.base_renewal_period %>" /> 
<input type='hidden' name='quoted_unit_price-<%= i %>' value="<%=   billing.price(product.unit_price) 
%>" /> 
<p><input type='radio' name='add-product' value='<%= product.specific_type.html %>:<%= i 
%>:base_renewal_period,quoted_unit_price,domain' /><%= billing.currency_symbol.html %><%= 
billing.price(product.unit_price, :use_tax_prefs) %> 
<% if product.base_renewal_period != 'never' %> 
every <%= product.unit_period.to_s_short.html %> 
<% end %> 
<% if product.setup_fee != 0 %> 
plus a one off fee of <%= billing.currency_symbol.html %><%= sprintf("%.2f", if billing.include_tax? 
then billing.price(product.setup_fee) else product.setup_fee end) %> 
<% end %> 
<% if product.has_free_products? %> 
<br /> 
includes free domains 
<% product.free_products_list.each do | free_product | %> 
<%= free_product["free_name"] %> 
<% end %> 
<% end %> 
* 
</p> 
<% i = i + 1 %> 
<% end %> 
<p><input type='submit' value='Add to Basket'/></p> 
</form> 
<% unless basket.nil? or basket.empty? or no_upsell? %> 
<p><a href='basket?add-no-product=package'>No thank you, please continue with my order 
...</a></p> 
<% end %> 
<% if not billing.tax_applies? %> 
<% elsif billing.include_tax? %> 
<p>* Includes <%= billing.tax_name %></p> 
<% else %> 
<p>* Excluding <%= billing.tax_name %></p> 
<% end %> 

如果有人能指出我在做什麼錯誤或我錯過了什麼或者不改變我將不勝感激! 非常感謝提前。 奈傑爾

回答

0

看來,你有你的另一部分周圍i = i + 1無與倫比的end

+0

非常感謝你 - 整理它。乾杯,你是一個傳奇! – 2010-05-30 13:16:55