Tag: mongoid

工厂女孩+ Mongoidembedded文件夹具

假设您有以下mongoid文档: class User include Mongoid::Document embeds_one :name end class UserName include Mongoid::Document field :first field :last_initial embedded_in :user end 如何创build一个初始化embedded式名字和最后一个字母的工厂女孩​​工厂? 另外你怎么做embeds_many关系?

Mongoid 3 + Heroku(MongoHQ)导致Moped :: Errors :: OperationFailure

使用Rails 3,从Mongoid 2.x升级到Mongoid 3.x后,我的Heroku + MongoHQ设置停止工作。 有趣的是,我的开发和testing框架,以及我的整个testing套件都很好。 我怀疑问题是与我的mongoid.yml文件,但我已经尝试search文档,谷歌和stackoverflow,并使用所有build议的格式,包括: heroku mongohq和mongoid Mongo :: ConnectionFailure或实际上这个: https:/ /gist.github.com/2900804 更新7月16日:这是我的mongoid.yml文件看起来,尝试了多个东西后+ 从MongoHQ的Jasonbuild议 : development: sessions: default: database: development hosts: – localhost:27017 test: sessions: default: database: test hosts: – localhost:27017 production: sessions: default: uri: <%= ENV['MONGOHQ_URL'] %> options: skip_version_check: true safe: true (据我的理解,它基本上和上面的链接一样,只是它使用了uri;我尝试了另一种方式,把MONGOHQ_URL分成了单独的字段,但是没有帮助) 我试着将mongoid设置为3.0.0rc,并将版本留在我的Gemfile中。 使用github版本由于HTTPS证书或其他原因而失败,所以我没有多次尝试它。 动作控制器说的是这样的: Moped::Errors::OperationFailure in Home#index Showing /app/app/views/home/index.html.haml […]

批量插入/更新使用Mongoid?

我GOOGLE和所有其他人,但我没有find答案。 问题是: 嗨,我怎样才能批量插入与Mongoid到MongoDB?

MongoDBselect_id的数组中的哪个位置?

在mongo db中可以select像SQL这样的集合文档: SELECT * FROM collection WHERE _id IN (1,2,3,4); 或者如果我有一个_id array我必须一个接一个地select,然后重新array/object的结果?

MongoDB中“id”和“_id”字段的区别

从MongoDB文档中使用字段ID或_ID有什么区别? 我这样问,因为我通常使用“_id”,但是我在文档中看到了这种sorting({id:-1}): http : //www.mongodb.org/display/DOCS/Optimizing+Object+IDs# OptimizingObjectIDs-Sortbyidtosortbyinsertiontime 编辑 原来的文件是错的。

在mongoid中select不为空或空的地方

我修改了一个模型,所以它包括一个新的领域,如… field :url, :type => String 我使用activeadmin,所以当我创build一个新的条目@model.url是空的,并且在改变模式之前创build的条目是零。 我如何select两个? 我努力了: # Returns nils and strings Model.where(:url.ne => "").count # Returns strings and "" Model.where(:url.ne => nil).count # Returns strings, nils and "" Model.where(:url.ne => ["", nil]).count 或者,如果有这种情况的最佳做法,请让我知道。

在Mongoid安装后使用Active Record生成器?

我通过Mongoid集成使用MongoDB,以及项目中的ActiveRecord。 我想为主动logging生成迁移,并且当我运行时,Mongoid是默认的。 rails g migration 任何想法如何指定AR作为我的默认发生器迁移,模型等? 谢谢!

Mongoid或MongoMapper?

我已经尝试了MongoMapper,它function完备(提供几乎所有的ARfunction),但使用大型数据集时性能不是很满意。 有没有人比较Mongoid? 任何性能收益?

如何实现has_many:通过与Mongoid和mongodb的关系?

使用Rails指南中的这个修改过的示例,如何使用mongoidbuild模关系“has_many:through”关联? 挑战是,mongoid不支持has_many:通过ActiveRecord。 # doctor checking out patient class Physician < ActiveRecord::Base has_many :appointments has_many :patients, :through => :appointments has_many :meeting_notes, :through => :appointments end # notes taken during the appointment class MeetingNote < ActiveRecord::Base has_many :appointments has_many :patients, :through => :appointments has_many :physicians, :through => :appointments end # the patient class Patient < ActiveRecord::Base has_many […]