Show only some words from post as preview
ruby-on-rails, ruby-on-rails-3, ruby-on-rails-3.1
Solution
Know the builtin tools.
Problem
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> <% } %> ```