In Rails 5.2.3, I need to render a partial which takes an optional block.
# users/_user.html.erb
...
<% if block_given? %>
<%= yield %>
<% else %>
<h1>Goodbye world</h1>
<% end %>
...
However block_given?
returns true regardless of which version I choose to go with:
<%# Version 1 - block_given? returns true %>
<%= render partial: "users/_user" do %>
<h1>hello world</h1>
<% end %>
<%# Version 2 - block_given? also returns true %>
<%= render partial: "users/_user" %>
What's going on here and why is this happening?