MongoMapper - NameError(未初始化常量 User::Message)
红宝石 - 1.9.2 导轨 - 3.1.1 MongoMapper - 0.9.1
非常奇怪。这段代码曾经运行良好。突然间,当你遇到这样的事情时,它就会中断:
class MyClass
def self.test
MyClass.all
end
end
所以我将它们更改为:
class MyClass
def self.test
self.all
end
end
这修复了它,但现在它产生了这个错误:
NameError (uninitialized constant User::Message)
对于此代码:
def get_messages_with_user(user)
all_messages = Message.where(:$or => [{:sender_id => self.id, :recipient_id => user.id, :is_active => true}, {:sender_id => user.id, :recipient_id => self.id, :is_active => true}]).sort(:created_at.asc).all
all_messages.reject{ |message| message.sender == self && message.introducer_id.present? }
end
知道这意味着什么吗???最糟糕的是,如果我们部署到 Heroku,这种情况就不会发生。只发生在本地...
Ruby - 1.9.2
Rails - 3.1.1
MongoMapper - 0.9.1
Very weird. This code used to work fine. All of a sudden when you have things like this, it breaks:
class MyClass
def self.test
MyClass.all
end
end
So I changed them to:
class MyClass
def self.test
self.all
end
end
And that fixed it, but now it's spawned this error:
NameError (uninitialized constant User::Message)
for this code:
def get_messages_with_user(user)
all_messages = Message.where(:$or => [{:sender_id => self.id, :recipient_id => user.id, :is_active => true}, {:sender_id => user.id, :recipient_id => self.id, :is_active => true}]).sort(:created_at.asc).all
all_messages.reject{ |message| message.sender == self && message.introducer_id.present? }
end
Any idea what that means??? The worst part is, if we deploy to Heroku, it doesn't happen. Only happens locally...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎需要文件的东西在我们的开发系统上不正确。
做:
解决了问题。
It seems as though something with requiring files is not right on our dev sytems.
Doing:
Solved the problem.
你确定它可以在 Heroku 上运行吗?检查日志。
Are you sure it is working on Heroku? Check the logs.