使用 rails 显示弹出框

Display popover with rails

我尝试用 rails 和 bootstrap 创建弹出窗口,如下所示:

        <%= content_tag(:a, role: "button", data: {
                        content: "#{image_tag('/user.png')}",
                        toggle: "popover",
                        content: "Click here"
            }) %>

但是不知何故当我渲染页面时显示如下(它没有遇到html):

{:data=>{:content=>"Click here", :toggle=>"popover"}}

在检查模式下 html 看起来像这样:

<a>{:data=&gt;{:content=&gt;"Click here", :toggle=&gt;"popover"}}</a>

我做错了什么?谢谢!

您忘记为标签添加值(第二个参数):

<%= content_tag(:a, 'your button', role: "button", data: { content: "#{image_tag('/user.png')}", toggle: "popover", content: "Click here" }) %>