Bugs: Browse | Submit New | Admin

[#2803] :limit necessary after upgrading Rails to 0.14.3

Date:
2005-11-09 10:38
Priority:
3
Submitted By:
Bragi Ragnarson (bragi)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
:limit necessary after upgrading Rails to 0.14.3

Detailed description
Rails 0.14.3 modified blank? method behaviour for Numeric. It always returns false (as oposite to previous version that
returned true if given Numeric value was 0).

As this change is necessary from Rails point of view it breaks acts_as_versioned making :limit option mandatory.

Proposed fix:

In method clear_old_versions use zero? method instead of blank?

--- acts_as_versioned.old.rb    2005-11-09 11:46:01.000000000 +0100
+++ acts_as_versioned.rb        2005-11-09 11:46:11.000000000 +0100
@@ -180,7 +180,7 @@
         # Clears old revisions if a limit is set with the :limit option in <tt>acts_as_versioned</tt>.
         # Override this method to set your own criteria for clearing old versions.
         def clear_old_versions
-          return if self.class.max_version_limit.blank?
+          return if self.class.max_version_limit.zero?
           excess_baggage = send(self.class.version_column).to_i - self.class.max_version_limit
           if excess_baggage > 0
             sql = "DELETE FROM #{self.class.versioned_table_name} WHERE version <= #{excess_baggage} AND
#{self.class.versioned_foreign_key} = #{self.id}

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item