Skip to content

Instantly share code, notes, and snippets.

@mrpunkin
Created January 31, 2013 20:44
Show Gist options
  • Select an option

  • Save mrpunkin/4686269 to your computer and use it in GitHub Desktop.

Select an option

Save mrpunkin/4686269 to your computer and use it in GitHub Desktop.
class Challenge < ActiveRecord::Base
has_many :challenge_photos, :dependent=>:destroy
has_many :photos, :through=>:challenge_photo
end
class ChallengePhoto < ActiveRecord::Base
belongs_to :challenge
belongs_to :photo
before_destroy :optout
def optout
Rails.console.log("Opting out")
end
end
class Photo < ActiveRecord::Base
has_many :challenge_photos, :dependent=>:destroy
has_many :challenges, :through=>:challenge_photos
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment