Question

i want to save my text message in same format as it is typed ans display it in the same format.

Suppose i type:

Hi,
   How r u? how is your daddy?

 Thanks & regards
 Your friend

but it will dispalyed as

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

in my view file i have something like this:

<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>

I am using rails 3.0.6. Is their any way to show the message as it is typed, i am sure their is something as i want but unable to get those. Any help will be thankful.

Was it helpful?

Solution

Hello friends i have got a solution. Rails has a built in method "simple_format"

And it is so simple to use and works well. Thanks a lot to this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top