rake 脚本中未初始化的常量 ActiveRecord 模型
我正在使用 Rails 2.3.2 和 ruby 1.8.7。我的 rake 脚本遇到了一些问题。看起来它根本无法在生产环境中加载任何 ActiveRecord 模型。使用开发环境真是太奇怪了。这是我的 rake 脚本:
task :indexing, :domain_name, :needs => :environment do |t, args|
ActiveRecord::Base.establish_connection(RAILS_ENV)
unless args.domain_name.blank?
portals = [Portal.find_by_domain_name(args.domain_name)]
else
portals = Portal.actives
end
end
有什么建议吗?
I'm using rails 2.3.2 with ruby 1.8.7. I got some problems with my rake scripts. It seems it cannot load any activerecord model with production environment at all. It's so weird that is working with development environment. Here is my rake script:
task :indexing, :domain_name, :needs => :environment do |t, args|
ActiveRecord::Base.establish_connection(RAILS_ENV)
unless args.domain_name.blank?
portals = [Portal.find_by_domain_name(args.domain_name)]
else
portals = Portal.actives
end
end
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除
ActiveRecord::Base.built_connection(RAILS_ENV)
。这部分已经加载您的环境:
=> :环境
Remove
ActiveRecord::Base.establish_connection(RAILS_ENV)
.This part loads your environment already:
=> :environment