I was curious: in an ERB file, when passing a block to a view helper, why does this work:
<%= div_for @thing do |x| %>
<%= x %>
<% end %>
while this doesn't?
<%= div_for @thing {|x| x.to_s} %>
In Ruby, do...end
is exactly the same as {...}
, so why not in ERB? Note aside: I can use x
on its own on the second line above because its .to_s
method returns the field I want to render. Sorry if this has been asked before, I wasn't able to find a similar question (found a similar answer though).