Link_to, anchors, and <a href name="link_name">

I see that the following creates an anchor tag.

link_to “link”, :anchor => “same_page_link”

However, how do I create an tag? link_to
doesn’t seem to support a :name option.

Any ideas on the syntax, or a better way to accomplish this?

Thanks!

ruby needs to know where ‘options’ ends and ‘html_options’ begins…
use curly braces:
link_to ‘link’, {:anchor => ‘same_page_link’}, :name => ‘same_page_link’

ruby needs to know where ‘options’ ends and ‘html_options’ begins…
use curly braces:
link_to ‘link’, {:anchor => ‘same_page_link’}, :name => ‘same_page_link’

Thanks Jeff,

That works!

Well, I did have to add the empty brackets before :name in order to
placehold the :options hash.

link_to ‘link’, {:anchor => ‘same_page_link’}, {}, :name =>
‘same_page_link’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs