Skip to content

Instantly share code, notes, and snippets.

@DefV
Created September 24, 2013 12:11
Show Gist options
  • Save DefV/6683824 to your computer and use it in GitHub Desktop.
Save DefV/6683824 to your computer and use it in GitHub Desktop.
class Artist < ActiveRecord::Base
has_many :tracks
accepts_nested_attributes_for :tracks
end
class Track < ActiveRecord::Base
before_destroy :check_track
def check_track
return false if created_at > 1.week.ago
end
end
Artist.first.update_attributes(track_attributes: {id: 4, _destroy: '1'})
# I want this to give an exception / validation errors if the check_track returns false. At the moment it just silently fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment