Rails: using link_to to make a link without href

后端 未结 8 1842
情书的邮戳
情书的邮戳 2020-12-29 19:05

How can I use the link_to helper to make a link without an href attribute? I want to make a link exclusively for a javascript action, I don\'t want

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 19:25

    An example for rails 5 would be:

    <%= content_tag("a", image_tag("/logo.png"), class: "navbar-brand") %>

    This would render as:

    Logo

    This is similar to niels' answer but with a nested image_tag and a class.

    Source: Rails API

提交回复
热议问题