Rails - HighVoltage - link anchor with title

44 views Asked by At

I am using the High_Voltage gem to integrate static pages in my rails gem. I figured out how to link to anchors within a page (thanks to this previous answer. Now I also want to add a pop-up title to the links. I just randomly tried

link_to "About", page_path('indexpage', anchor: "aboutsection", title: "MyAboutTitle")

But this renders to

<a href="/pages/indexpage?title=MyAboutTitle#aboutsection">About</a>

and, logically, does not produce the desired result.
Any suggestion? Thanks!

1

There are 1 answers

0
R. Sierra On

According to the Rail API for link_to to add html options, the title argument should be placed third in the method call, like this:

link_to "About", page_path('indexpage', anchor: "aboutsection"), title: "MyAboutTitle"

and it will output:

<a href="/pages/indexpage#aboutsection" title="MyAboutTitle">About</a>