title: Limiting characters/words in view - ruby on rails
body: <p>I am displaying recent comments on the home page of a very simple blog application I am building in Ruby on Rails. I want to limit the number of characters that are displayed from the 'body' column of the comments table. I am assuming I can just add something to the end of the code for &lt;%=h comment.body %> but I don't know what that would be yet as I am new to both Ruby and Rails. </p>
  
  <p>Here is the code I have in the /views/posts/index.html.erb file:</p>
  
  <pre><code>&lt;% Comment.find(:all, :order =&gt; 'created_at DESC', :limit =&gt; 5).each do |comment| -%&gt;
      &lt;p&gt;
          &lt;%=h comment.name %&gt; commented on 
          &lt;%= link_to h(comment.post.title), comment.post %&gt;&lt;br/&gt;
          &lt;%=h comment.body %&gt;
          &lt;i&gt; &lt;%= time_ago_in_words(comment.created_at) %&gt; ago&lt;/i&gt;
      &lt;/p&gt;
      &lt;% end -%&gt;
  </code></pre>