简体   繁体   English

为什么Rails不显示以句点结尾的字符串

[英]Why is Rails not displaying strings that end in a period

If I save this string to an address field: 如果我将此字符串保存到地址字段:

11060 Westmoor Dr. 11060 Westmoor博士

It doesn't display in the UI. 它不会显示在UI中。

But if it saved without the period at the end, 但是,如果它保存的最后没有句号,

11060 Westmoor Dr 11060 Westmoor博士

Then is does display in the UI. 然后在UI中确实显示。

Why does the period cause the string not to display? 为什么句点导致字符串不显示?

I'm displaying it like this: 我正在这样显示它:

<%= f.label "#{user_event.address1}, ", class: 'info_label' %>

Thanks! 谢谢!

I'm not sure why you're using a label in this manner. 我不确定您为什么以这种方式使用标签。 The label should be used as a field name. 标签应用作字段名称。 So, rather than output the string of someone's address, you should use it like: 因此,与其输出某人地址的字符串,不如使用它:

<%= f.label :address_line_1 %>
<%= f.text_field_tag :address_line_1 %>

Rails is removing punctuation here because you can't have "." Rails在这里删除标点符号,因为您不能有“。” as method names 作为方法名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM