Questions tagged [mongoid6]

Mongoid 6 is major version 6 of Mongoid, the officially supported ODM (Object-Document-Mapper) framework for MongoDB in Ruby.

Ruby ODM framework for MongoDB.

Docs for Mongoid 6.

Mongoid community projects https://github.com/mongoid

29 questions
0
votes
1 answer

How do I rename a collection with Mongoid 7.x and MongoDB 3.x

I have a test app using Ruby 2.2.2 and am using Mongoid 7.0.0 and Moped 1.5.3 with MongoDB 3.6.2 - we are upgrading an ancient codebase using Mongoid 4.x and MongoDB 2.6 and found numerous breaking-changes in the API along the way The most serious…
blue18hutthutt
  • 3,191
  • 5
  • 34
  • 57
0
votes
0 answers

Retrieving Collection from mLab

I am using a MongoDB on mLab to store a basic collection of boardgames which I wish to show in my Ruby app. I have completed a tutorial that uses Mongoid to implement this locally, but so far I can't get it working with the mLab instance of the…
coderwurst
  • 161
  • 3
  • 14
0
votes
1 answer

NameError: undefined method 'options' for class

When I create instance of class, Error is raised NameError: undefined method 'options' for class 'Product'. DB: MongoDB 3.6 Class Product include Mongoid::Document include Mongoid::Timestamps include Mongoid::Attributes::Dynamic …
Amar A
  • 65
  • 8
0
votes
1 answer

Rails force to_param to return something even when not persisted

I need to handle a particular case of generating email views with URLs constructed from non-persisted data. Example : assume my user can create posts, and that triggers a post creation notification email, I'd like to send the user an example of fake…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
0
votes
1 answer

Rails - framework for sending test emails and disable DB write

I have a website with several types of customer (eg Admin, Manager, Marketing, etc.) Using Rails, I am asked to send test emails to those people so they can preview the emails on their own email client + firewall restrictions + see if the email go…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
0
votes
1 answer

Mongoid 6 alias field name

I'm upgrading a Rails 4.2 app with mongoid 5.2, but after the upgrade I find that options, client field names are not allowed. This is the conclusion I arrived to after looking at mongoid code and seeing this exception: NameError - undefined method…
0
votes
1 answer

Mongoid - Detect if there are results on the next page

Using Mongoid, how can I check if given the limit/results_per_page options there is a next page ? Suppose my scope is MyCollection.page(@page).per(@per) Calling .count will compute the total number of results across all pages. But how do I detect…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
0
votes
1 answer

mongoid 'with' option behavior changed with >6.0

Let me start with my use case. I have two different instance of mongoid database hosted per region based with similar model. And depending on user input, the code gets the results from respective mongo instance in my rails app. I am not sure what…
R. V.
  • 129
  • 1
  • 7
0
votes
1 answer

Rails 5 + Mongoid virtual attribute

I am trying to make a simple user signup functionality with Rails 5 and Mongoid. My user model and controller look like this: user.rb class User include Mongoid::Document include Mongoid::Timestamps validates_presence_of :email …
0
votes
1 answer

manually construct associations to get around the eager loading limitations with mongoid?

suppose i have 3 models, A, B and C: class A include Mongoid::Document has_many :bs ... class B include Mongoid::Document belongs_to :a has_many :cs ... class C include Mongoid::Document belongs_to :B …
user1130176
  • 1,772
  • 1
  • 23
  • 33
0
votes
0 answers

FactoryGirl.create does not work while upgrading mongoid version from 5 to 6. Below is the issue I run into while running rspec test

This is the place where is create a test table: factory :reward_scheme, class: RewardsModels::RewardScheme do uid { ExpectedData::COSTA_UID } scheme_type { "bricks" } reward_type { "menu"} company_address {…
0
votes
2 answers

Mongoid 6, Rails 5, HABTM "unpermitted parmeter"

I've been doing RoR for years, but this is my first project with Mongo (also my first api-only project). I'm having a rough time with HABTM associations and I suspect it has to do with params, but I'm not sure what else to try. Here's what I've…
nilatti
  • 528
  • 1
  • 4
  • 14
0
votes
1 answer

Rails Puma Server: Undefined `extract_multipart' or `before_create' on logout action

I'm unable to logout out of my own page because I get a undefined method Puma error whenever I try. Most of the times it's extract_multipart, but I've also seen before_create. This is what is shown in the blank page whenever I click logout Puma…
Vicente Rivera
  • 43
  • 1
  • 1
  • 6
0
votes
1 answer

Polymorphism ignored by mongoid

In a nutshell I run into the following error with validations / model saving NameError (uninitialized constant PolymorphicAssociation): Background & code Consider the following models (omitting Mongoid::Document) class User has_many…
1
2