Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created July 16, 2010 10:32
Show Gist options
  • Select an option

  • Save bogdan/478216 to your computer and use it in GitHub Desktop.

Select an option

Save bogdan/478216 to your computer and use it in GitHub Desktop.
after_update do |m|
m.album.update_attribute(:band_id, m.band_id) if m.album.is_a?(Single) && m.band_id_changed?
if m.audio_id_changed? && m.audio_id.present? # audio => audio
audio = Audio.find( m.old_audio_id )
if audio.is_a?( Single ) # single => album
audio.destroy
end
end
true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment