在轨道上显示红宝石中的最大符号?

时间:2018-01-22 08:24:58

标签: ruby-on-rails ruby database each

如何显示maximin 250个符号?对于 post.description

  
<% @microposts.each do |post| %>
    <% a = post.had %>
    <% b = post.needs.to_f %>
    <% count = (a/b)*100 %>
      <div class="col-md-12 post card-1 card-3">
        <h3 class="pad-h3"><%= post.title %> <text class="needs"> Needs  <%= post.needs %>$</text></h3>
        <div class="row pad">
          <div class="col-md-6"><a href="/help/id<%= post.id %>"><img class="img2" src="<%= post.image1 %>">
            <h3 class="fun"><%= count %>% Funded</h3>
          </a></div>
          <div class="col-md-6"><p><%= post.description %></p></div>
        </div>
        <div class="row"><a href="/help/id<%= post.id %>" class="butt2" data-wipe="Show more information">Show more information</a></div>
       </div>
  <% end %>

Sometext SometextSometextSometextSometext Sometextv Sometextv vvvvvvSometextSometextSometextSometextSometextSometextSometextSometextSometextSometextSometextSome textSometextS dometext SometextSometextSometextSomete xtSometextSometextSometextSometextSometextSometext

1 个答案:

答案 0 :(得分:1)

Rails有truncate text helper

<%= truncate post.description, length: 250 %>