簡體   English   中英

Rails3中的消息格式

[英]message format in rails3

我想將我的文本消息保存為相同的格式,然后以相同的格式顯示它。

假設我輸入:

Hi,
   How r u? how is your daddy?

 Thanks & regards
 Your friend

但它將顯示為

Hi, How r u? how is your daddy? Thanks & Regards Your friend

在我的視圖文件中,我有這樣的東西:

<table class="display stylized" id="act_details">
       <thead>
          <tr>
                 <th>Message Details</th>

          </tr>
        </thead>
            <tbody> 
               <!--<tr>
                  <td colspan="2">Message from <strong><%= @message.from %></strong></td>
               </tr>-->
               <tr>
                 <td colspan="2"><label>Subject:</label> <%= @message.subject %></td>
               </tr>
              <!-- <tr>
                 <td colspan="2" wrap><label>Message:</label> <%= word_wrap(@message.description, :line_width => 80 ) %></td>
               </tr>-->
                <% @replies.each do |reply|%>
                  <tr>
                    <td colspan ="2" wrap><label> Sent by <%= reply.from.capitalize %> on <%= reply.created_at %> </label> <br/><%= word_wrap(reply.description, :line_width => 80)%></td>
                  </tr>
                <%end%>
        </tbody>      
</table>

我正在使用Rails 3.0.6。 是他們以任何方式顯示鍵入的消息嗎,我確定他們是我想要的東西,但無法獲得這些信息。 任何幫助將是感激的。

朋友您好我有解決方案。 Rails具有內置方法“ simple_format

而且它是如此簡單易用且效果很好。 非常感謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM