This project is archived and is in readonly mode.
link_to does not respect options like :confirm and :popup if url is specified as part of :options itself
Reported by Rajalakshmi Ramesh | February 3rd, 2010 @ 01:46 PM
The problem occurs when link_to is used as follows
<%=link_to "Delete asset",:action=>"delete",:controller=>"post",:id=>post.id,:confirm=>"Do u want
to delete this post"%>
The generated link looks like this
<a href="/post/delete/14?confirm=Do+u+want+to+delete+this+post">
However using
<%=link_to "Delete asset","post/delete/#{post.id}",:confirm=>"Do u want to delete this post"%>
gives the proper resultComments and changes to this ticket
-
Samuel Danielson February 4th, 2010 @ 04:21 PM
The proper results in
<%=link_to "Delete asset","post/delete/#{post.id}",:confirm=>"Do u want to delete this post"%>
are due to you passing :confirm as the third argument, which is "html_options". Break :confirm into the third arg so it gets passed as html_options.
<%=link_to "Delete asset",{:action=>"delete",:controller=>"post",:id=>post.id},{:confirm=>"Do u want to delete this post"}%>
On a related note this has changed in edge. Some keys in html_options are converted to data-#{key}. Others, like :href, override the default. This is for the new javascript and rest stuff.
<%= link_to 'hello from edge', '', :batman_sidekick => 'robin', :confirm => 'Sure?' %>
<a href="" batman_sidekick="robin" data-confirm="Sure?">hello from edge</a>
-
Rishav Rastogi April 11th, 2010 @ 12:01 AM
- Assigned user set to Ryan Bigg
Invalid. Not using link_to properly as mentioned in the above comment.
-
Ryan Bigg April 11th, 2010 @ 12:08 AM
- State changed from new to invalid
I will mention also here that it's probably best to use the RESTful helpers for this (assuming you set them up in config/routes.rb first!
<%= link_to 'delete asset', post_path(post), :method => :delete, :confirm => "Do you want to delete this post?" %>
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>