views:

316

answers:

1

I'm trying to get the Vestal Version gem to work, but I keep getting this error:

>> 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

The relevant method is here:

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

Any thoughts?

A: 

I am an idiot: the gem includes a Version class and I has defined an empty Version class as well (removing all its methods).

Horace Loeb