我正在使用Ruby on Rails 3.2.1和model @post。問題是我想僅在第一個應用頁面上顯示第一段或某些詞,而不是所有內容。我該怎麼做?只顯示文章中的部分文字作爲預覽
指數:
<% @posts.each{|posts| %>
<h1 class="title"><%= link_to posts.title, posts %></h1>
<p class="byline" style="text-align: right; font-weight: bold;">Raksts izveidots: <%= posts.created_at.utc.strftime("%d.%m.%Y") %></p>
<div class="entry">
<p><%= raw posts.content %></p>
</div>
<p class="meta"><a href="#" class="more">Read More</a> <a href="#" class="comments">Comments</a> (33)</p>
<% } %>
簡單而簡單!謝謝! :) – RydelHouse 2012-04-13 14:11:29
不客氣:) – apneadiving 2012-04-13 14:46:11