Ruby on Rails – rake routes giving error about a model-Collection of common programming errors
I have this model:
class Kpi
include Mongoid::Timestamps
#include Mongoid::Document
field :number_of_users, :type => Integer, :default => 0
end
and when I ran rake routes, I got this error:
rake aborted!
undefined method `field' for Kpi:Class
any idea why that would happen?
Thanks!
-
rake routes
loads your environment -> loads your code. So if there’s an error in your code, it won’t show your routes. In your case, you should uncommentinclude Mongoid::Document
EDIT
So it’s not working even with it ? Hm, maybe include
Document
beforeTimestamps
? Kind of a long shot here
Originally posted 2013-11-09 19:41:34.