1
美好的一天,我在查看這個代碼,它會產生軌道截斷錯誤的參數數目(3 2)
wrong number of arguments (3 for 2)
Extracted source (around line #7):
4: <h3 class="<%= cycle('color_1', 'color_2') %> ">
5: <%= link_to sanitize(article.title),article %>
6: </h3>
7: <% output_text = truncate(article.text, 40, "...") %>
8: <span><%= sanitize(output_text) %>
9: <%= link_to ' ... full ->', article %></span>
10: <span style="display: none">
這就是我檢查截斷http://paulsturgess.co.uk/articles/37-how-to-truncate-text-in-ruby-on-rails
如果我寫
<% output_text = truncate(article.text, 40) %>
我得到
undefined method `reverse_merge!' for 40:Fixnum
對於這類事情,你可能想看看[API](http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html #method-i-truncate)而不是在將來的博客文章中:-) – Mischa 2012-08-13 07:10:05