简体   繁体   中英

Text_area empty

I'm trying to display the content of my message class using text_area helper but when I load the page the text area is always blank.

<div id="messages">
<% for message in @channel.messages %>

      <h3><div class="title"><%=h message.description %></div></h3>
      <div class="moderator">Sent By: <%=h message.moderator %><br>On <%= message.created_at.strftime('%b %d, %Y') %></div>
      <div class="description">Channel Summary:<br><%= text_area("Message",  simple_format(message.content), :cols => 40, :disabled=> true, :rows => 10) %><!/div>
  <% end %>
  </div>
</div>

You should use the text_area_tag helper in this case. text_area is meant to be used when using form_for .

http://apidock.com/rails/ActionView/Helpers/FormTagHelper/text_area_tag

<%= text_area_tag("message",  simple_format(message.content), :cols => 40, :disabled=> true, :rows => 10) %>

api docs say you use method incorrectly. smth like that would be correct text_area(:message, :content, :cols => 40, :disabled=> true, :rows => 10)

but if you want to call simple_format on content, use text_area_tag instead .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM