为什么我会收到此错误:请确保包含 ActiveModel::Naming
我正在安装一个名为 Completeness-fu 的 gem。
这是我收到的错误:
completeness-fu-0.6.0/lib/completeness-fu/active_model_additions.rb:12:in `define_completeness_scoring': please make sure ActiveModel::Naming is included so completeness_scoring can translate messages correctly (CompletenessFu::CompletenessFuError)
这是什么意思?
I am installing a gem called completeness-fu.
This is the error I get:
completeness-fu-0.6.0/lib/completeness-fu/active_model_additions.rb:12:in `define_completeness_scoring': please make sure ActiveModel::Naming is included so completeness_scoring can translate messages correctly (CompletenessFu::CompletenessFuError)
What does that mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ActiveModel::Naming
创建一个#model_name 对象上的方法
。 Completeness-fu gem 似乎需要它来用于
#define_completeness_scoring
方法。来自自述文件:
更新
见评论;根本问题似乎是 gem 中的一个错误(截至 2011 年 6 月 29 日)。这可以使用以下代码进行猴子修补(假设 Ruby 1.9)。唯一的变化是使用 self.singleton_class.include?(ActiveModel::Naming) 来获得正确的响应。
警告!!!
这是一个超级临时(且脆弱)的猴子补丁,我真的不建议在生产能力中实际使用这样的代码。
更好的选择是为此找到一个不同的 gem,与作者合作修复它,分叉该项目并自行修复它,然后在您的项目中使用该分叉(更多信息),或者只是使用 gem 作为起始设计在您的应用程序中本地重建此功能。
ActiveModel::Naming
creates a#model_name
method on your object. The completeness-fu gem seems to require it for the#define_completeness_scoring
method.From the readme:
Updated
See comments; the underlying issue seems to be a bug in the gem (as of 29 June, 2011). This could be monkey-patched using the following code (assuming Ruby 1.9). The only change is using
self.singleton_class.include?(ActiveModel::Naming)
to get the proper response.Warning!!!
This is a super temporary (and fragile) monkey-patch, and I really don't recommend actually using code like this in a production capacity.
The better options would be to find a different gem for this, work with the author to get it fixed, fork the project and fix it yourself then use that fork in your project (more info) or simply rebuild this functionality in your app locally using the gem as a starting design.