问题
I'm trying to use a block in a helper,
but that's giving me this error:
SyntaxError - syntax error, unexpected ')'
...rbout.concat(( green_title do ).to_s); _erbout.concat "\n   ...
...                               ^
(erb):4254: syntax error, unexpected end-of-input, expecting ')'
; _erbout.force_encoding(__ENCODING__)
                                      ^:
  (erb):1649:in `'
here's how I'm calling it:
  <%= green_title do %>
    text
  <% end %>
and here's my helper:
  def green_title(&block)
    capture do 
      concat content_tag(:h3) do
        yeld
      end
    end 
  end
回答1:
Your block is being associated with concat instead of content_tag
Try using parentheses to identify what belongs where.
concat(content_tag(:h3) do
  yield
end)
来源:https://stackoverflow.com/questions/62511665/with-a-block-in-rails-4