Vestal版本不起作用

时间:2009-08-27 01:05:56

标签: ruby-on-rails versioning vestal-versions

我正在尝试使Vestal Version 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

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我是一个白痴:gem包含一个Version类,我也定义了一个空的Version类(删除它的所有方法)。