Can I use a link_to to generate a link with a span inside?

后端 未结 5 1704
醉话见心
醉话见心 2020-12-31 03:29

I am basically trying to get this result:

        
            Log in
            

        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 03:42

    The simplest way to do it is by using html_safe or raw functions

    <%= link_to 'Log In'.html_safe %>
    

    or using raw function (recommended)

    <%= link_to raw('Log In') %>
    

    Simple as it can get !!

    Don’t use html_safe method unless you’re sure your string isn’t nil. Instead use the raw() method, which wont raise an exception on nil.

提交回复
热议问题