Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(STI) Revisions of destroyed records does not update 'type' and 'revision_type' attributes #11

Open
skgma opened this issue Dec 18, 2009 · 0 comments

Comments

@skgma
Copy link

skgma commented Dec 18, 2009

This is using Single Table Inheritance. The issue is easily remediated with my childish method:

  acts_as_revisable do
    revision_class_name "AccountRevision"
    except [:update_tracker, :last_login_on, :last_update_on, :last_login_at,
            :password_changed_on, :updated_at, :revoked_on, :resumed_on]
  end
  
  acts_as_revisable :on_delete => :revise
  
  after_revise_on_destroy :arod!
  
  def arod!
    print "poop poop!!\n"
    self.revisable_type = self.type
    self.type = "#{self.type}Revision"
    self.revisable_original_id = self.id
    
    if self.save
      return true
    else
      return false
    end
  end

hahaha, it says "poop poop." What a cute definition (snuggles).

I'm porting my models into a new Rails project for cleanliness sake and just realized this issue again. Example:

>> RacfAccount.count
=> 9319
>> RacfAccountRevision.count
=> 16
>> Account.count
=> 9319
>> AccountRevision.count
=> 26
>> 

The AccountRevision is showing records for which the '.destroy' method has been used. The 'type' attribute continues to reflect "RacfAccount" and not "RacfAccountRevision", and the 'revision_type' is set to NULL. However, when doing a simple revision (but not destroy) of a RacfAccount record, it will correctly set the 'type' and 'revision_type' attributes (by default).

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant