Vestalバージョンのgemを機能させようとしていますが、次のエラーが発生し続けます。
>> Song.first.version
=> 8
>> Song.first.revert_to(7)
NoMethodError: undefined method `>' for #<Version:0x231bddc>
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:260:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/laserlemon-vestal_versions-0.4.2/lib/vestal_versions.rb:80:in `revert_to'
from (irb):3
関連する方法は次のとおりです。
def revert_to(value)
chain = versions.between(version, value)
return version unless chain.size > 1
new_version = chain.last.number
backward = chain.first > chain.last
backward ? chain.pop : chain.shift
timestamps = %w(created_at created_on updated_at updated_on)
chain.each do |version|
version.changes.except(*timestamps).each do |attribute, change|
new_value = backward ? change.first : change.last
write_attribute(attribute, new_value)
end
end
何かご意見は?