开发者

Text_area empty

开发者 https://www.devze.com 2023-01-28 10:37 出处:网络
I\'m trying to display the content of my message class usingtext_area helper but when I load the page the text area is always blank.

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><%开发者_JS百科= 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消