Only show non blank attributes for a model in views in Rails
- by Senthil
Say I've a user model and there are bunch of user info, like email, birthdate, location, telephone number etc.
What's the simplest way of hiding the attributes that are blank?
I've doing something like
<% if blog.title.empty? -%>
<p>Body: <%=h blog.body %></p>
<p>Comments: <%=h blog.comments %></p>
…