Sch*_*ems 6 ruby ruby-on-rails link-to
如果我想转到我可以使用的页面上的"whatever_id",我如何使用link_to来正常转到页面上的特定(html)ID
<a href="http://www.example.com/index/mypage#whatever_id>Click Here</a>
Run Code Online (Sandbox Code Playgroud)
但我想使用我的link_to
<%= link_to "click here" , {:action => "mypage", :controller => "index" }, :id => "#whatever_id"%>
Run Code Online (Sandbox Code Playgroud)
辅助方法.有谁知道如何做到这一点?可能吗?
Rails 2.3.4
Mic*_*man 26
link_to可以将锚点添加到URL.
从文档中,
link_to "Comment wall", profile_path(@profile, :anchor => "wall")
# => <a href="/profiles/1#wall">Comment wall</a>
Run Code Online (Sandbox Code Playgroud)
在你的情况下,你可能想要,
<%= link_to "click here" , {:action => "index", :controller => "mypage", :anchor => "whatever" } %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6772 次 |
| 最近记录: |