Heroku rake任务未初始化为MongoMapper模型的常量 [英] Heroku rake task uninitialized constant for MongoMapper model
问题描述
我有一个很小的rake任务,只是将一个新的延迟作业插入队列中。我插入了一行调试行
desc'开始处理新的rss feed文章'
task:process_new_articles => :environment do
config = RSS_CONFIG
feeds = config ['rss_feeds']
把Article.all
feeds.each do | feed |
Delayed :: Job.enqueue ProcessNewArticlesJob.new(feed,config ['settings'])
end
end
它似乎正确加载配置信息。但是,在运行任务时,我收到未初始化的恒定文章错误。文章是一个MongoMapper模型。我已经验证了与数据库的连接(在MongoLab上)工作正常。
这一切在本地都很有效。
<
更奇怪的是,引用Article.all使用heroku run console工作得很好。
-
堆栈跟踪不会显示太多:
2011-12-04T22:33:02 + 00:00 app [start.1]:rake aborted!
2011-12-04T22:33:02 + 00:00 app [start.1]:未初始化的常量Article
<
我不小心命名了我的文章模型文件,
Article.rb,并且大写字母为A.这导致Heroku在运行rake environment时没有采用它。
奇怪而且很可能是一个bug?
I have a tiny rake task which just sticks a new delayed job into the queue. I've inserted a debug line
desc 'Start processing new rss feed articles'
task :process_new_articles => :environment do
config = RSS_CONFIG
feeds = config['rss_feeds']
puts Article.all
feeds.each do |feed|
Delayed::Job.enqueue ProcessNewArticlesJob.new(feed, config['settings'])
end
end
It seems to be loading the config info correctly. But I'm getting a "uninitialized constant Article" error upon running the task. Article is a MongoMapper model. I've verified the connection to the database (on MongoLab) works fine.
This all works great locally.
--
What is even more bizarre is that referencing Article.all using "heroku run console" works just fine.
--
The stack trace doesn't show much:
2011-12-04T22:33:02+00:00 app[start.1]: rake aborted!
2011-12-04T22:33:02+00:00 app[start.1]: uninitialized constant Article
Found the problem and it is totally weird.
I had accidentally named my Article model file, "Article.rb" with a capital A. This caused Heroku to not pick up on it upon running "rake environment".
Strange and most likely a bug?
这篇关于Heroku rake任务未初始化为MongoMapper模型的常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!