Hide table header if there is no column attribute - Ruby on rails
<p>Here is a index.html.erb. How do I hide the table header, such as Remark, with a method when no records exists in remark attribute column? Preferably without using JavaScript.</p>

<p>index.html.erb  </p>

<pre><code>&lt;table id = "kola" class="table listing text-center"&gt;
                &lt;% has_remark = collection_has_remark?(@aslani361s) %&gt;
                &lt;thead&gt;
                    &lt;tr class="tr-head"&gt;
                        &lt;td&gt;Date&lt;/td&gt;
                        &lt;td&gt;Description&lt;/td&gt;
                        &lt;td&gt;Amount&lt;/td&gt;
                        &lt;td&gt;Discount&lt;/td&gt;
                        &lt;td&gt;Paid&lt;/td&gt;
                        &lt;td&gt;Balance&lt;/td&gt;
                        &lt;td&gt;DelnDel&lt;/td&gt;
                        &lt;% if has_remark %&gt;
                        &lt;td&gt;Remark&lt;/td&gt;
                        &lt;% end %&gt;
                        &lt;td&gt;Hide&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/thead&gt;
&lt;/table&gt;
</code></pre>

<p>However I am able to hide the remark attribute values like as below ;</p>

<p>_aslani361.html.erb</p>

<pre><code>&lt;% if aslani361.remark.present? -%&gt;
    &lt;td class="col-1"&gt;&lt;%= aslani361.remark %&gt;&lt;/td&gt;
&lt;% end %&gt;
</code></pre>

<p>aslani361s_helper.rb</p>

<pre><code>module Aslani361sHelper
    def collection_has_remark?(collection)
        collection.each do |aslani361|
            if aslani361.remark.present?
                return true
            end
        end
    end
end
</code></pre>

<p>aslani361.rb</p>

<pre><code>class Aslani361 &lt; ActiveRecord::Base

end
</code></pre>

<p>Any suggestions are most welcome.</p>

<p>Thank you in advance.</p>