I have a model called NoteCategory, which is functioning as a join table between Notes and Categories.
Up till this point, I have used scaffolding to do everything in RoR. I'm trying to learn how to do some stuff more manually.
I want to have a link that will appear next to each category on a note, that will remove the category from the note. So I need to create a route that will delete the entry from the join table.
So far I have created a controller
class NoteCategoriesController < ApplicationController
def destroy
notecategory = NoteCategory.find(params[:id])
notecategory.destroy
respond_to do |format|
format.html { redirect_to(notes_url) }
format.xml { head :ok }
end
end
end
I then added this line to routes.db
map.resources :note_categories
And here is the link in the view:
<%= button_to 'Delete', :confirm => 'Are you sure?', :controller => "notecategories",:action => :destroy %>
When I click the button, I get this error message:
No route matches "/notecategories/destroy" with {:method=>:post}
What am I doing wrong? Thanks for reading.