型号名称“查询"不适用于 rails 3? [英] Model name "Query" doesn't work with rails 3?

查看:37
本文介绍了型号名称“查询"不适用于 rails 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 rails 3.0.3,我有一个名为 Query 的模型.当我从应用程序调用全部"或查找"时(我从用户模型调用它)它说

I am using rails 3.0.3 and I have a model named Query. When I call "all" or "find" on Query from application (I was calling it from User model) it says

"NoMethodError (undefined method `all' for ActiveRecord::AttributeMethods::Query:Module):"

当我检查 Rails 时,有模块查询

As I checked in rails there is module query in

ActiveRecord::AttributeMethods::Query`  

在:

activerecord/lib/active_record/attribute_methods/query.rb:

但如果我从控制台调用它,它工作正常.

But if I call it from console, it works fine.

任何帮助、信息?

谢谢和问候,普拉文.

推荐答案

Query 可能是一个保留字.它没有列在保留字的官方列表中,但是rails发现了一个冲突文件.只需更改模型名称作为解决方法.

Query is probably a reserved word. It isn't listed in the official list of reserved words, but rails is finding a conflicting file. Just change the model name as a workaround.

这篇关于型号名称“查询"不适用于 rails 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆