views:

35

answers:

1

I am trying to use this redirect_to

redirect_to :controller => :note_categories, :action => :destroy, :note_id => params[:id]

This is the URL that results

http://localhost:3000/note_categories/272?note_id=272

and this is the error message

Unknown action
No action responded to show. Actions: destroy

The reason I am redirecting to the note_categories destroy action, and passing in the note id, is that in the destroy action, I am finding all the note_categories related to note, running some code on them, then destroying them. I know this isn't a great way to be doing this, but I couldn't use :dependant => :destroy because the code I have to run on the note_category before I delete it needs access to current_user, which can't happen in the note_category model.

So yeah, can someone please tell me what am I doing wrong in my redirect_to? Thanks for reading.

+2  A: 
John Topley
@John Topley - Thanks for your answer. That clears things up about redirect_to for me. Just wondering, could you please explain your last paragraph? Do you mean that I should be calling a method in the NoteCategory model from the destroy action of the Note controller, passing it current_user?
ben
@ben Possibly, you'd have to post your controller and model code. Perhaps as a separate question...
John Topley
@John I've worked it out, thanks so much for your help.
ben
@ben You're welcome. I'm glad you got it working.
John Topley