ruby on rails:文本文件格式 [英] ruby on rails: text filed formatting

查看:39
本文介绍了ruby on rails:文本文件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 Ruby on Rails 从 Word 文档复制并粘贴到文本字段.

但是所有格式(空格、粗体和其他)在文本文件中都消失了.

我刚刚得到了没有任何格式的简单文本行.

我读过需要使用简单格式工具...但我希望用户能够将文本复制并粘贴到文本字段而无需进行任何调整.我的意思是,我想提前进行所有调整,用户只需复制和粘贴文本并获得所有格式,就像在 Word 文档中一样.

带有文本字段的文件链接如下.https://gist.github.com/tatyana12/2f9d39c2f6e4f8fabea5e70e11ef>31

我还有 Application.html.erb 文件:

https://gist.github.com/tatyana12/15c27d542091b04f3c52adf

如果我现在没有 id = "edit" 如何初始化编辑器?

如何给这个文件添加一些额外的代码样式?

尝试将您的字段包装在 show.html.erb 或任何您想使用 simple_format 显示它的地方,例如:

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

参见 http://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format 了解更多信息.

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've just got the simple lines of text without any formatting.

I've read that need to use Simple format tool... but I want that a user be able just to copy and past a text to text field without doing any adjustments. I mean, I want make all adjustment in advance and the user could just copy and past the text and got all formatting, the same as in Word doc.

The link to file with text field as below. https://gist.github.com/tatyana12/2f9d39c2f6e4f8fabea5e70e11eaf310

Also I have Application.html.erb file:

https://gist.github.com/tatyana12/15c27d542091b04f3c3adfdfd252b7f4

How to initialize editor if I don't have id = "edit" right now?

How to put some code extra style to this file?

解决方案

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.

这篇关于ruby on rails:文本文件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆