【发布时间】:2012-03-09 02:54:12
【问题描述】:
我对 Rails 和 mongodb 有一个小问题。我有一个在开发模式下运行良好的小应用程序。它也可以在生产模式下工作,但是当我进入 rails 控制台时,我什么也看不到。
user-001@marcus:/var/www/webapp% rails c RAILS_ENV="production"
You did not specify how you would like Rails to report deprecation notices for your RAILS_ENV=production environment, please set config.active_support.deprecation to :log, :notify or :stderr at config/environments/RAILS_ENV=production.rb
Loading RAILS_ENV=production environment (Rails 3.2.1)
1.9.3p0 :001 > User.all
=> []
我的 config/initialize/mongo.rb 看起来像这样
MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
MongoMapper.database = "webapp-#{Rails.env}"
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
MongoMapper.connection.connect if forked
end
end
但它看起来也很空旷
$ mongo localhost:27017/mail1up-production
MongoDB shell version: 1.8.2
Fri Feb 17 18:26:00 *** warning: spider monkey build without utf8 support. consider rebuilding with utf8 support
connecting to: localhost:27017/webapp-production
> db.mycollection.stats()
{ "errmsg" : "ns not found", "ok" : 0 }
>
我做错了吗?为什么我看不到数据库中的数据?如何测试?
【问题讨论】:
-
你发现问题了吗?
标签: ruby-on-rails ruby-on-rails-3 mongodb mongomapper