lib/vestal_versions.rb in laserlemon-vestal_versions-0.2.5 vs lib/vestal_versions.rb in laserlemon-vestal_versions-0.2.6

- old
+ new

@@ -39,10 +39,11 @@ end module InstanceMethods def build_version @version = nil + versions.reload unless changes.blank? if versions.empty? if new_record? versions.build(:changes => attributes) else @@ -54,12 +55,10 @@ versions.build(:changes => changes) unless new_record? end end def version - @version ||= begin - new_record? || (last_version = versions.last).nil? ? 1 : last_version.number - end + @version ||= versions.maximum(:number) end def revert_to(value) chain = versions.between(version, value) return version unless chain.size > 1