how to add a string to the path in link_to of ruby on rails
For example I have this code:
<%= link_to 开发者_JAVA百科"Start", start_path(:id=>1,:box=>1)%>
the id
and the box
are parameters right?
and for example, it generated this url: http://localhost:3000/start?id=1&box=1
How can I add a string to it, to make look like this:
http://localhost:3000/start?id=1&box=1#box_1
Use the :anchor
key:
<%= link_to "Start", start_path(:id => 1, :box => 1, :anchor => 'box_1')
And to answer your first question, yes, id
and box
are parameters. They are passed in to the request as part of the params
hash.
精彩评论