Hi,
I'm learning rails and have run into what for me is a difficult problem.
I have the following associations with a galleries_pictures and a
pictures_questions join table:
class Picture < ActiveRecord::Base
has_and_belongs_to_many :questions
has_and_belongs_to_many :galleries
class Question < ActiveRecord::Base
has_and_belongs_to_many :pictures
class Gallery < ActiveRecord::Base
has_and_belongs_to_many :pictures
In the edit question view, a question and its associated picture(s) can
be edited. My problem is, I cannot figure out how to delete the picture
in the question and at the same time not delete it from the gallery ie
delete the pictures_questions association but not the
galleries_pictures association.
The action called from the view deletes the row in both join tables:
def destroy
@picture = Picture.find(params[:id])
@picture.destroy
Thanks!