[英]Paper_trail gem: uninitialized constant VersionsController::Version
I had this working fine following the Railscast episode by Ryan Bates and then some weeks later I went back to check on it and it was borked. 在Ryan Bates的Railscast剧集之后,我的工作正常,然后几周后我回去检查它并且它被塞住了。 Now I'm getting this error whenever I hit the undo button:
现在,每当我点击撤消按钮时,我都会收到此错误:
uninitialized constant VersionsController::Version 未初始化的常量VersionsController :: Version
I have it set up exactly as in the screencast, but I have no clue what might have broken it. 我的设置与截屏视频一样,但我不知道可能会破坏它。
Problem is on line 3 apparently: 问题明显在第3行:
class VersionsController < ApplicationController
def revert
@version = Version.find(params[:id])
@version.reify.save!
redirect_to :back, :notice => "Undid #{@version.event}"
end
end
Any suggestions? 有什么建议么?
http://railscasts.com/episodes/255-undo-with-paper-trail http://railscasts.com/episodes/255-undo-with-paper-trail
The latest versions of Papertrail actually namespace the Version class as PaperTrail::Version. 最新版本的Papertrail实际上将Version类命名为PaperTrail :: Version。 This will fix the problem immediately.
这将立即解决问题。
Here is an example: 这是一个例子:
def revert
@version = PaperTrail::Version.find(params[:id])
if @version.reify
@version.reify.save!
else
@version.item.destroy
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.