whyhtml.erb generate a html structure not like it should be?

the HTML.ERB like this, and then it generate a html, it. the <table> indent not it shoud be, and the second <tr> also indent not the noraml. why it generate a html like that?

second, I think everytme I should check empty object like object.blank? and then iterate the object is very ugly. how to change this ugly behavior?

the HTML.ERB like this, and then it generate a html, it. the <table> indent not it shoud be, and the second <tr> also indent not the noraml. why it generate a html like that?

Your Ruby code is indented (it has some whitepace infront) and then you suppress whitespace at the end. So the next line (which is indented) starts directly after the previous indents.

Two choices:

1) Don't worry about it. I'd rather have nicely laid out code than prioritise nicely laid out HTML.

2) Remove the code indents:

<h1>h1_title</h1> <% unless @obs.blank? -%>   <table border="0" cellspacing="0" class="normal_table">     <tr>       <th>operation</th>     </tr> <% @obs.each do |ob| -%>     <tr>       <td><%= ob.created_at %></td>     </tr> <% end -%>   </table> <% end -%>

second, I think everytme I should check empty object like object.blank? and then iterate the object is very ugly. how to change this ugly behavior?

Seems reasonable to me; not so ugly. But you could move the "@obs.each" row out to a partial and pass in @obs as the collection. It does the same thing, but might look "prettier" to you :slight_smile: