此代碼顯示屬於當前社區的CommunityTopic的所有記錄。 如何限制數量爲10條記錄以在此處顯示?如何限制在視圖中加載的記錄數?
<ul>
<% @community.community_topics.each do |topic| %>
<li>
<%= link_to topic.title, community_topic_path(@community, topic) %>
<%= link_to topic.user.user_profile.nickname, community_topic_path(@community, topic) %>
</li>
<% end %>
</ul>
你檢查嗎? http://stackoverflow.com/questions/533837/automatic-counter-in-ruby-for-each – theMarceloR