Q: Using &block to pass html to method How can I pass a block to a method. For example: 
# in the view
button(link) do
  '<div>html content</div>'
end

def button(&block)
  block
end

I have the following code which is working: 
# in helper file
def button(&block)
  link_to '/' do
      block.call.html_safe
  end
end


# in the view
button {'<div>html content</div>'}


A: So, you just want to pass the block on to link_to? Do this.
def button(&block)
  link_to '/', &block
end


A: You are likely messing things up. What you are trying to achieve is easily achievable without any yield magic, with plain old good method parameter:
def button html
  link_to '/', html.html_safe
end

button '<div>html content</div>'

If one wants to yield a value from a block, do something with it and pass it further, one might:
def button
  raise unless block_given?
  λ = Proc.new
  link_to '/', &-> { λ.call.html_safe }
end

button { '<div>html content</div>' }


A: use yield:
def new_button(link)
  link_to link do
      yield.html_safe if block_given?
  end
end

