开发者

Model name "Query" doesn't work with rails 3?

开发者 https://www.devze.com 2023-01-28 13:10 出处:网络
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

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):"

As I checked in rails there is module query in

ActiveRecord::AttributeMethods::Query`  

In:

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

But if I call it f开发者_运维知识库rom console, it works fine.

Any help, information?

Thanks and regards, Pravin.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号