rails has_many :post causing an uninitialized constant Post error
I've got a fairly simple app at the moment, trying to learn rails 3 beta & mongodb.
I have a User and the User has messages.
When I try to create the User, I get an error
uninitialized constant Message
the error is traced back to the User model line 22 which is
has_many :posts, :dependent => :destroy
If I remove the :dependent, I still get the error, if I comment out the entire line, the user gets created.
Nowhere in the create user method does it even look for messages, so I guess I have two questions
1) why is rails looking for messages 2) how do I debug this?
------additional info ------------------
I just created another model for 'fri开发者_运维知识库ends', and used the has_many, and had no problem creating the file as long as the has_many messages is commented out.
So the problem isn't with has_many, but i'm having trouble debugging it.
When I generated my model, I had it plural. Going back and doing it singular fixed this issue for me.
rails g model notification ...
instead of
rails g model notifications ... (WRONG)
Unfortunately I solved the problem, but don't know what I did.
I was changing some file names, and renamed everything to Post(s). That didn't work, so I went back to Message(s), and now it works.
Unfortunately I don't get to learn from my mistake on this one.
精彩评论