我正在使用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