Questions tagged [mongoid]

Mongoid is the official Ruby Object-Document-Mapper (ODM) for MongoDB.

Mongoid (pronounced mann-goyd) is an Object-Document-Mapper (ODM) for MongoDB written in Ruby. Mongoid as of version 5 is under the control and guidance of MongoDB as the official Ruby ODM.

The philosophy of Mongoid is to provide a familiar API to Ruby developers who have been using Active Record or Data Mapper, while leveraging the power of MongoDB's schema-less and performant document-based design, dynamic queries, and atomic modifier operations.

4728 questions
2
votes
1 answer

"event-calendar" gem with mongoid

I want to use 'event_calendar' in my rails application. My application is configured for mongoid instead of ActiveRecord. So How can I use this gem in my rails application? When I use event_calendar by following…
user1856354
2
votes
0 answers

Modeling product variations in Rails3/Mongoid with an embeds_many / embedded_in relation....?

I know this is a (somewhat) common question but I'm a newbie and I always appreciate a second (or 100th) pair of eyes on a problem I'm been noodling. I'm wondering if I'm taking the right approach here -- I'm trying to model a product with several…
nlh
  • 1,055
  • 1
  • 10
  • 15
2
votes
2 answers

I am using rails cast omniauth and i get this error

I am using Mongodb as database in rails and i got error when using /auth/linkedin/callback NoMethodError in AuthenticationsController#create undefined method []' for nil:NilClass Rails.root: /home/prem/Music/heronhrm Application Trace | Framework…
regmiprem
  • 735
  • 2
  • 14
  • 41
2
votes
1 answer

How should I architect a reviews model for reviewing products by a user using mongoDB/mongoid?

I am very new to mongodb/mongoid and was wondering about the best way to architect a system that enables users to review products. User and Product will be individual collections. But they both need access to the Review model for displaying the…
perseverance
  • 6,372
  • 12
  • 49
  • 68
2
votes
0 answers

Mongoid performance measuring

I'm building a web app using Mongoid, Sinatra and Rspec for testing. What kind of technique or gem can be used with this stack to measure performance of queries?
hs-
  • 1,016
  • 9
  • 17
2
votes
3 answers

How should I use a instance variable at different parts of a view?

This might be a noob question. But I couldn't figure it out by myself. In my application' I'm using Rails 3.2.8 with Mongoid and MongoDB. I have a instance variable like this: ProgramsController < ApplicationController @program =…
scaryguy
  • 7,720
  • 3
  • 36
  • 52
2
votes
1 answer

Mongoid where query using count

I have the next models, using Mongoid: class Album have_many :images end class Image belongs_to :album end I want to get only albums that have any images: Album.all.select{ |a| a.images.count > 0 } But it return an array and I need a…
rjurado01
  • 5,337
  • 3
  • 36
  • 45
2
votes
2 answers

Finding nested values in pymongo

I have a data: {'_id': 0, 'values': [{'value': 1, 'value_type': 'type1'}, {'value': 2, 'value_type': 'type2'}, {'value': 134, 'value_type' : 'type1'}, {'value': 2564, 'value_type': 'type212'}]} {'_id': 1, 'values': [{'value': 136, 'value_type':…
Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
2
votes
1 answer

Sort by the average of two attributes

I need to sort the query by the average of two attributes, something like Story.scoped.order_by('(importance + points)/2'). As I saw on MongoDB and Origin documentation, this don't seems to be possible. Do I need to create a third attribute with the…
irio
  • 1,401
  • 14
  • 11
2
votes
2 answers

Undefined method 'column' mongoid and bootstrap

I have a scaffold aplication with mongoid and did: rails g bootstrap:install but when I put: rails g bootstrap:themed Contratos I have this…
Zauu
  • 55
  • 5
2
votes
2 answers

Embedded or referenced relations

I use mongodb and mongoid gem and I'd like to get some advice. I have an app where User has many Markets and Market has many Products. I need to search for the products, say in a specific price range, in all (or any) the markets which belong to the…
hs-
  • 1,016
  • 9
  • 17
2
votes
1 answer

Trying to figure out what kind of relationships I should use

Sinatra, Mongoid 3 There 4 models: User, Book, FavoriteBooks, ReadBooks, NewBooks. Each user has their list of the favourites, read and new books. A book belongs to a list. But it's also possible to request an information about any book which means…
Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
2
votes
0 answers

Custom fields with mongoid

I started to use the mongoid gem in my project, and I'm a little confused about how it store and get the information on the database. I have fields of specifics types in my models, but when I get it from the DB it returns a Hash. Here is my…
2
votes
3 answers

get counter nested model mongoid

2 models: Class User include Mongoid::Document has_many :reports end Class Report include Mongoid::Document belongs_to :user end I need a query to get all users have 6 or more reports, something like:. Users.where(reports.count > 5) I use…
hyperrjas
  • 10,666
  • 25
  • 99
  • 198