Why is Rails not displaying strings that end in a period

↘锁芯ラ 提交于 2020-03-28 04:22:45

问题


If I save this string to an address field:

11060 Westmoor Dr.

It doesn't display in the UI.

But if it saved without the period at the end,

11060 Westmoor Dr

Then is does display in the 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!


回答1:


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 "." as method names



来源:https://stackoverflow.com/questions/17264307/why-is-rails-not-displaying-strings-that-end-in-a-period

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!