Created
June 19, 2014 23:13
-
-
Save leepfrog/0bfb1371cc829cca67c4 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 Author < ActiveRecord::Base | |
has_one :history, as: :related | |
end | |
class History < ActiveRecord::Base | |
belongs_to :related, polymorphic: true | |
validates :related_id, presence: true, uniqueness: {scope: :related_type} | |
validates :related_type, presence: true, uniqueness: true | |
end | |
# What i'd like to be able to do | |
a=Author.first | |
# Do this to unset the history -- stage it for deletion | |
a.history=nil | |
# Purges the history object at this point | |
a.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment