0

I have a Rails 3.2 application and my "Show" view lists the fields and values for people. For this example let's assume the values are

name
address1
address2
city
state
zip

I can't be assured that all data elements will have values for each label. For example address2 will seldom be filled in. That results in the values for city, state and zip to align with the wrong labels.

Is there a way I can make things line up with their appropriate label without having to throw it into a table? I'd like to avoid that mess if possible.

Thanks in advance.

4

1 回答 1

1

这将取决于您如何显示数据。这是一种方法。

<% if(lable_value.empty? || lable_value.nil?) %>
  <%= "<br />".html_safe %>
<% else %>
  <%= lable_value %>
<% end %>
于 2013-01-18T17:14:21.347 回答