Created
September 24, 2013 12:11
-
-
Save DefV/6683824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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