ruby on rails: text filed formatting

后端 未结 2 600
离开以前
离开以前 2021-01-16 13:38

I tried to copy and past from Word document to text field using Ruby on Rails.

But all formatting( spaces, bold and other) are disappeared on text filed.

I

相关标签:
2条回答
  • 2021-01-16 13:58

    Have a go at wrapping your field in your show.html.erb or wherever you want to display it with simple_format, for example:

    <%= simple_format(@object.description) %>
    

    See http://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format for more info.

    0 讨论(0)
  • 2021-01-16 14:12

    I've solved this problem by implementing SKEditor. There is a lot of tutorial how to implement this editor. I (as a lot of other users) have problem that my text wasn't formatted because this editor is not compatible with turbo links. So, I disable turbo links in some files, and as result I have the text formatted.

    0 讨论(0)
提交回复
热议问题