Ruby on rails 在Rails URL中包含哈希参数

Ruby on rails 在Rails URL中包含哈希参数,ruby-on-rails,high-voltage,Ruby On Rails,High Voltage,我在一个页面上有指向pages\u路径('index')的链接。 这很好,只是我希望每个链接都指向页面的特定部分 所以每个链接看起来都像 www.example.com/pages/index#locations 现在我正在使用一个相当黑客的解决方案来生成这个链接 link_到“About”,“page_路径('index')}#About” 有更好的方法来实现这一点吗?您只需要使用锚定选项: link_to "About", page_path('index', anchor: "about"

我在一个页面上有指向
pages\u路径('index')
的链接。 这很好,只是我希望每个链接都指向页面的特定部分

所以每个链接看起来都像

www.example.com/pages/index#locations

现在我正在使用一个相当黑客的解决方案来生成这个链接

link_到“About”,“page_路径('index')}#About”


有更好的方法来实现这一点吗?

您只需要使用
锚定
选项:

link_to "About", page_path('index', anchor: "about")