# Link\_to not asking confirmation (js)

**URL:** <https://www.ruby-forum.com/t/link-to-not-asking-confirmation-js/156608>\
**Category:** Rails\
**Created:** [December 30, 2008, 9:59pm UTC](https://www.ruby-forum.com/t/link-to-not-asking-confirmation-js/156608 "2008-12-30T21:59:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ad7895/32.png) [@pablo](https://www.ruby-forum.com/u/pablo)\
**Post date:** [December 30, 2008, 9:59pm UTC](https://www.ruby-forum.com/t/link-to-not-asking-confirmation-js/156608/1 "2008-12-30T21:59:43Z")

</div>

Hi, I have this link\_to helper

\<%= link\_to “edit”, :action =\> ‘edit’, :id =\> @pirate, :confirm =\>  
‘should edit?’ %\>

It should (in order to what I read in apidock) prompt me for  
confirmation via javascript confirm, but it doesn’t.

Any idea why?

Also when I set the :id attribute, either @pirate or @pirate.id  
work… why is that, and what’s the preferred form?

Thanks!

---

<div class="post-metadata">

**Author:** ![pablo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ad7895/32.png) [@pablo](https://www.ruby-forum.com/u/pablo)\
**Post date:** [December 30, 2008, 11:37pm UTC](https://www.ruby-forum.com/t/link-to-not-asking-confirmation-js/156608/2 "2008-12-30T23:37:45Z")

</div>

On Dec 30, 8:59 pm, Pablo F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi, I have this link\_to helper
> 
> \<%= link\_to “edit”, :action =\> ‘edit’, :id =\> @pirate, :confirm =\>  
> ‘should edit?’ %\>
> 
> It should (in order to what I read in apidock) prompt me for  
> confirmation via javascript confirm, but it doesn’t.

If you check the html generated you’ll noticed that the url has a  
confirm parameter. If you check apidoc again you’ll see that the  
confirm option needs to be passed in the second options hash, ie  
link\_to ‘blah’, {options for url}, {other stuff here}

> Any idea why?
> 
> Also when I set the :id attribute, either @pirate or @pirate.id  
> work… why is that, and what’s the preferred form?

Because if you pass an activerecord object as the :id for a url rails  
calls to\_param on it, which by default returns id. The preferred form  
these days would be to have the appropriate routes and do link\_to  
‘edit’, edit\_pirate\_path(@pirate)

Fred

---

<div class="post-metadata">

**Author:** ![pablo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ad7895/32.png) [@pablo](https://www.ruby-forum.com/u/pablo)\
**Post date:** [December 31, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/link-to-not-asking-confirmation-js/156608/3 "2008-12-31T17:21:30Z")

</div>

Thanks so much, I was passing the args in the wrong order as you stated.

On Tue, Dec 30, 2008 at 7:36 PM, Frederick C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > It should (in order to what I read in apidock) prompt me for
> 
> Because if you pass an activerecord object as the :id for a url rails  
> calls to\_param on it, which by default returns id. The preferred form  
> these days would be to have the appropriate routes and do link\_to  
> ‘edit’, edit\_pirate\_path(@pirate)
> 
> Fred
> 
> > Thanks!

–  
Fernandez, Pablo.
