I’m trying to remove the association between an Actor and a Movie, associated through an Appearance model. I’d like to do this by clicking a link on the actor’s edit page. I have found the method I need to use (@actor.movies.delete()), but I’m unsure where to put it and how to get the right movie id.
Below is my partial for the movie fields in the actor form:
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.check_box :_destroy %>
<%= f.label :_destroy, "Remove Movie" %>
The above works if I add :allow_destroy => true to my Actor model, but what I want to do is rewrite it so it doesn’t delete the movie, only the association.
What I needed to do was, of course, delete the Appearances rather than the movie objects themselves.