I am using Ruby on Rails 3.2.1 and model @post. Problem is that I want to show only first paragraph or some words on my first app page like a preview, not all the content. How I can do that?
index:
<% @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>
<% } %>
Maybe I'm not understanding the question but if content is a string
posts.content[0,20]
will give you the first 20 characters.
Know the builtin tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With