Questions tagged [mongoid3]

Version 3 of Mongoid, an Object-Document-Mapper (ODM) for MongoDB with Ruby. Use this tag for questions relating to this specific version.

Version 3 of Mongoid (an Object-Document-Mapper (ODM) for MongoDB). For a deeper description of Mongoid, see the main Mongoid tag.

Primary tag:

211 questions
1
vote
2 answers

How to drop a specific database using Mongoid?

Mongoid.default_session.database_names gives me an array of database names. I want to delete a specific database. How would I do that? Mongoid.default_session.drop() always seems to drop the default database even if I override the current database…
1
vote
0 answers

father/mother/children relationships in Mongoid?

I have the same problem as described here has_many :through multiple has_one relationships? But I use Mongoid instead ActiveRecord. And I have a problem in relations has_one, because they do not have :through. How to solve this problem? Or reject…
Almaz88
  • 11
  • 1
  • 1
1
vote
3 answers

Moped: Rename mongodb collection

How can one rename a collection, using Mongoid + Moped driver? Is there a Moped implementation of http://docs.mongodb.org/manual/reference/command/renameCollection/?
Vlad Zloteanu
  • 8,464
  • 3
  • 41
  • 58
1
vote
0 answers

Enforcing field type using Mongoid 3

I'm upgrading from Mongoid 2. I have the following model: class Person include Mongoid::Document field :names, type: Array end The following used to raise an exception: p = Person.new p.names = 'stuff' Now under Mongoid 3, no exception is…
Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130
1
vote
1 answer

Strange Ghost Object appearing

I currently have 3 Models, UserModel (Devise), an ArticleModel and an CommentModel. I work with mongoid. class Comment include Mongoid::Document field :body, type: String field :created_at, type: Time, default: DateTime.now belongs_to…
cschaeffler
  • 453
  • 3
  • 5
  • 17
1
vote
1 answer

How to?: Mongoid 3 and Dragonfly configuration

I am trying to upgrade my app to mongoid version 3. In my dragonfly initializer I used to have this: app.configure_with(:imagemagick) app.configure_with(:rails) do |c| c.datastore = Dragonfly::DataStorage::MongoDataStore.new :db =>…
demersus
  • 1,185
  • 2
  • 10
  • 24
1
vote
0 answers

Mongoid3 + FactoryGirl Incompatible?

I just upgrade to Mongoid3 and Im getting a TON of these errors: TypeError: can't convert String into Integer The issue is always when Im trying to build a model that belongs_to another model and I assign the referenced model: @entry =…
LMH
  • 949
  • 9
  • 22
1
vote
1 answer

Mongoid Query DB by Virtual Attribute

BACKGROUND: I have Posts and Users, both of which HABTM Communities. In my Post model, I have a method for calculating a post's relevance to a given user by comparing how many communities they have in common as such: def relevance(user) …
neon
  • 2,811
  • 6
  • 30
  • 44
1
vote
1 answer

How to add functionality to Mongoid::Document from a gem?

I want to create a gem which adds some functionality to my models. How to define a custom keyword for a Mongoid model? E.g.: class Book include Mongoid::Document has_my_awesome_functionality end
Kenny Meyer
  • 7,849
  • 6
  • 45
  • 66
1
vote
0 answers

Heroku app - can't login with device and mongoid, monghq

I have a simple device, mongoid, mongoHQ, rails based app deployed to heroku. The user login gives an error. gemfile: source 'https://rubygems.org' gem 'rails', '3.2.3' group :development, :test do gem 'rspec-rails' end group :test do …
Sayanee
  • 4,957
  • 4
  • 29
  • 35
1
vote
1 answer

Cannot save a custom field (array) in ActiveAdmin and Mongoid 3.x

I've got a field "location", which is an array [lng, lat]. I have two input fields in the ActiveAdmin form, defined as follows f.inputs :name => "Location" do f.input :latitude f.input :longitude end In order to get latitude and longitude I…
Mike Bevz
  • 1,266
  • 1
  • 14
  • 20
1
vote
1 answer

Mongoid 3 gem dependency

I want to upgrade my mongoid gem to 3.0 so I can upgrade activeadmin-mongoid in order to get a new feature. My mongoid-mapreduce gem however has a dependency on 2.0. Is there a way around this? Is there a way to see if mongoid-mapreduce would still…
RailsTweeter
  • 1,625
  • 3
  • 18
  • 33
0
votes
1 answer

how include embedded Document in rails only query

The model Claim consists of a large number of fields. In claim controller index action querying claims with the only function, fields that are printed in the index list are querying from the db @claims = @claims.only(:nice_id, :brand_id, etc..…
Anand Jose
  • 638
  • 9
  • 26
0
votes
1 answer

Moped "invalid collection name"

I've recently upgraded mongoid to version 3.0.0 from 2.0 in my rails app. When performing an operation which saves an object (either existing or a new one) I'm getting Moped::Errors::OperationFailure: The operation: #
jacobi007
  • 11
  • 3
0
votes
1 answer

Filter nested attributes with ruby mongoid gem

I have define the scope below (within my model) to help me filter out certain un-required nested data. scope :active_inactive, -> { self.in({ state: ["current"], "events.type" => [ :active, :inactive, ] …
Ikenna
  • 989
  • 4
  • 12
  • 24