Using simple_format somehow modifies a models attribute in-place
This is a weird one. I have a page that simple_format's a comments attribute on an instance of a model. However on the same page is a form allowing this comment to be updated. When I simple_format the attribute, the form then shows this attribute in it's modified form (i.e. with paragraph tags etc...).
I can't see how this is happening unless somehow simple_format is modifying the models attribute in-place but how could that happen when it is executed like this:
simple_format @warranty.comments
outputs:
<p>Here are some comments</p>
and further down the page in the form, or even if we just call:
@warranty.comments
we get:
<p>Here are some 开发者_高级运维comments</p>
If I change it to:
simple_format @warranty.comments.clone
the behaviour goes away.
Am I missing something obvious here? I'd not expect a text helper to modify the original attribute unless it was called like @warranty.comments.simple_format!
This was a bug that was fixed earlier this month. The latest 3.1.0 should have the fix, but I'm not sure about the other versions.
精彩评论