title: How to setup restriction for view in a table tag?
body: <p>This is code of my view file, it shows multiple columns for the table. </p>
  
  <p>The restriction is working but columns are multiple.</p>
  
  <p> 
      
  </p>
  
  <pre><code>&lt;table class="table table-responsive"&gt;
      &lt;tr&gt;
          &lt;th&gt;Title&lt;/th&gt;
          &lt;th&gt;Description&lt;/th&gt;
  
      &lt;% obj.each do |article| %&gt;
          &lt;% if logged_in? &amp;&amp; current_user == article.user %&gt;
              &lt;th&gt;Edit&lt;/th&gt;
              &lt;th&gt;Show&lt;/th&gt;
              &lt;th&gt;Delete&lt;/th&gt;
              &lt;th&gt;Created By&lt;/th&gt;
              &lt;th&gt;Created At&lt;/th&gt;
              &lt;th&gt;Updated At&lt;/th&gt;
          &lt;% end %&gt;
  
      &lt;% end %&gt;
      &lt;/tr&gt;
  
  
      &lt;% obj.each do |article| %&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;%= article.title %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= article.description %&gt;&lt;/td&gt;
      &lt;% if logged_in? &amp;&amp; current_user == article.user %&gt;
  
          &lt;td&gt;&lt;%= link_to "Edit", edit_article_path(article), class: "btn btn-primary" %&gt; &lt;/td&gt;
          &lt;td&gt;&lt;%= link_to "show", article_path(article), class: "btn btn-success" %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to "Delete", article_path(article), method: :delete, data: {confirm: "Are you Sure?"}, class: "btn btn-danger" %&gt;&lt;/td&gt;
  
          &lt;td&gt; &lt;%= article.user.username if article.user %&gt; &lt;/td&gt;
          &lt;td&gt; &lt;%= time_ago_in_words(article.created_at) %&gt; ago.&lt;/td&gt;
          &lt;td&gt; &lt;%= time_ago_in_words(article.updated_at) %&gt; ago.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;% end %&gt;
  
      &lt;% end %&gt;
  &lt;/table&gt;
  
  &lt;%= link_to 'Back', root_path, class: "btn btn-primary btn-lg" %&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/eQLjn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eQLjn.png" alt="enter image description here"></a></p>