I have a button which is always present in the html, but by default is hidden with the css #comments_button{ display: none; }.
I want the button to appear if the notice has any comments. In _notice.html.erb:
<%= button_tag "Comments", id: "comments_button" do %>
<span>Comments</span>
<% end %>
<% if notice.comments.any? %>
*** get jQuery to do $("#comments_button").show(); ***
<% end %>
How do you call the jQuery from inside the ruby if/else loop?
Please note, the button should always be present in the html so I can't do this:
<% if notice.comments.any? %>
<%= button_tag "Comments", id: "comments_button" do %>
<span>Comments</span>
<% end %>
<% end %>