开发者

How to hide table header in view with no javascript?

开发者 https://www.devze.com 2023-04-05 10:07 出处:网络
Here is a index.html.erb. How do I hide the header, such as Description, with a method in helper file? Preferably without using javascript.

Here is a index.html.erb. How do I hide the header, such as Description, with a method in helper file? Preferably without using javascript.

  <tr>
    <th>Category</th>
    <th>Description</th>

  </tr>

Thanks开发者_JAVA技巧.


  <tr>
    <th>Category</th>
    <% if show_desc? %>
      <th>Description</th>
    <% end %>
  </tr>

UPDATE: Another way is to define and use in your view a helper like:

def description
 show_desc? ? "<th>Description</th> : ""
end

You can refactor this method how you like.

0

精彩评论

暂无评论...
验证码 换一张
取 消