In Rails, how can I allow some html in a text area?

前端 未结 6 2596
灰色年华
灰色年华 2021-02-19 21:35

I have a Rails app (blog) that I am creating. Very basic stuff. In my content area I have a text area for the content of the post. I am needing to include some html in the text

6条回答
  •  粉色の甜心
    2021-02-19 22:09

    With the forthcoming Rails 6, you will be able to use a new rich_text_area tag to create a rich text editor in your forms like this:

    <%= form_with(model: article) do |f| %>
      
    <%= f.label :content %> <%= f.rich_text_area :content %>
    <% end %>

    See Action Text Rails Guide

提交回复
热议问题