Search code examples
ruby-on-railslink-to

unnecessary characters getting added in URL when using rails link_to helper anchor tag


I'm trying to add #xyz to a link which is generated using rails link_to helper.

Following is my code:

<%= link_to('', edit_notification_path(:id => item.id,:type =>"requester_template", 
:notification_type => @notification_type,:anchor => "#xyz"), 
:class => 'icon-pencil-3' ) %>

But the generated URL looks like

email_notifications/3/edit/requester_template?notification_type=ticket#%23es

That is there is an extra %23 that gets added with the anchor.

What am I doing wrong here ? ( Rails beginner here )


Solution

  • You have to change :anchor => "#xyz"to :anchor => "xyz". The option :anchor already includes the #.