维斯塔版本不工作
我正在尝试让 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
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我是个白痴:gem 包含一个 Version 类,并且我还定义了一个空的 Version 类(删除其所有方法)。
I am an idiot: the gem includes a Version class and I has defined an empty Version class as well (removing all its methods).