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

Already on GitHub? Sign in to your account

deleted_in_original_table method #14

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants

Dear technoweenie and team,

We are using acts_as_versioned in our campus management platform of the technical
university of vienna (tiss.tuwien.ac.at) and are very happy with it.

I wrote a small convenience method that given a version model checks if
the original record has already been deleted. Test is also included in this patch.

Please feel free to pull the patch if you like, it should work out-of-the box.

All the best,

  • Johannes
deleted_in_orginal_table method for version models.
This method returns true when the record of a version model has been deleted
in the original table. Test is also included in this patch.

@technoweenie technoweenie commented on an outdated diff Apr 11, 2012

lib/acts_as_versioned.rb
@@ -245,6 +245,13 @@ def next
def versions_count
page.version
end
+
+ # Returns true if record was deleted in original table, else
+ # false.
+ #
+ def deleted_in_original_table
+ not original_class.exists?(self.send original_class.versioned_foreign_key)
+ end
@technoweenie

technoweenie Apr 11, 2012

Owner

What's going on with this indentation? Do you mind fixing that?

Hi there,

Hope that's ok now, don't know how this happened ..

  • Johannes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment