问题
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