I'm trying to use Rails' simple_format()
method, but it isn't working as examples online seem to indicate: It works on a double quoted string, but not a single quoted string, and it also doesn't work on text fields in models returned from my DB.
simple_format "Hello
World"
# Hello
# World
simple_format 'Hello
World'
# Hello
World
simple_format @model.hello_world
# Hello
World
simple_format "#{@model.hello_world}"
# Hello
World
Why does the method treat these string differently? I haven't seen anything in the examples or docs stating that this behavior is expected, specifically with strings provided from model fields. How can I display my dynamic content with formatting?
question from:
https://stackoverflow.com/questions/65951236/rails-simple-format-not-handling-some-strings 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…