# Passing params through destroy

**URL:** <https://www.ruby-forum.com/t/passing-params-through-destroy/184596>\
**Category:** Rails\
**Created:** [March 5, 2010, 1:22am UTC](https://www.ruby-forum.com/t/passing-params-through-destroy/184596 "2010-03-05T01:22:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 5, 2010, 1:22am UTC](https://www.ruby-forum.com/t/passing-params-through-destroy/184596/1 "2010-03-05T01:22:58Z")

</div>

I’m having a strange sort of problem. I’d like to pass a param when  
I’m deleting a record, but can’t seem to do it.

I’ve tried all sorts of variants of:

def destroy  
@note = Note.find( params[:id] )  
@patient = Patient.find( params[:patient\_id] ) # this is where  
I’m trying to pass a parameter  
@note.destroy

```
respond_to do |format|
  format.html { redirect_to :action => "index", :patient_id =>

```

@patient.id }  
format.xml { head :ok }  
end  
end

And I’ve tried all sorts of variants of:

\<%= link\_to ‘Delete’, note, :patient\_id =\> @patient, :confirm =\> ‘Are  
you sure?’, :method =\> :delete %\>

Which don’t work. Is there any way to pass params through delete?

TIA,  
Craig

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 5, 2010, 1:31am UTC](https://www.ruby-forum.com/t/passing-params-through-destroy/184596/2 "2010-03-05T01:31:10Z")

</div>

On Mar 4, 2010, at 4:21 PM, Dudebot wrote:

> you sure?’, :method =\> :delete %\>
> 
> Which don’t work. Is there any way to pass params through delete?

\<%= link\_to ‘Delete’, note\_path(note, :patient\_id =\>  
@patient.id), :confirm =\> ‘Are  
you sure?’, :method =\> :delete %\>

Assuming ‘notes’ is a restful route…

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 5, 2010, 6:48am UTC](https://www.ruby-forum.com/t/passing-params-through-destroy/184596/3 "2010-03-05T06:48:57Z")

</div>

def delete  
@note = Note.find( params[:id] )  
@patient = Patient.find( params[:patient\_id] ) # this is where  
I’m trying to pass a parameter  
@note.destroy

respond\_to do |format|  
format.html { redirect\_to :action =\> “index”, :patient\_id =\>  
@patient.id }  
format.xml { head :ok }  
end  
end

Try it Out ok

On Fri, Mar 5, 2010 at 5:51 AM, Dudebot [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> you sure?', :method =\> :delete %\>  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to  
> removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> .  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Thanks:  
Rajeev sharma
