jovhenni19
jovhenni19

Reputation: 450

how to add a string to the path in link_to of ruby on rails

For example I have this code:

<%= link_to "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

Upvotes: 0

Views: 611

Answers (1)

bricker
bricker

Reputation: 8941

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.

Upvotes: 3

Related Questions