Questions tagged [mongoid4]

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

Version 4 of Mongoid (an Object-Document-Mapper (ODM) for MongoDB)), which is compatible with Rails 4. For a deeper description of Mongoid, see the main Mongoid tag.

Primary tag:

Homepage

104 questions
0
votes
1 answer

Rails + Mongoid + Strong Parms failure

So, I'm relatively new to ruby and rails. I'm playing around with mongoid for my database, though the only knowledge I hold is using active record. I created a fresh project, being sure to skip active record so that I didn't have to perform the…
Johnny
  • 841
  • 3
  • 10
  • 25
0
votes
1 answer

How can I use form objects with mongoid in Rails 4

With Active record I can do the following to get form object. Rails 3 class TestForm extend ActiveModel::Naming include ActiveModel::Conversion include ActiveModel::Validations def persisted? false end end Rails 4 class TestForm include …
Atul
  • 258
  • 3
  • 14
0
votes
2 answers

rails g mongoid:config error

I get this error when ever I run this command rails g mongoid:config. Does anybody have any idea /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug/history.rb:1:in `require': cannot load such file -- readline…
Gardezi
  • 2,692
  • 2
  • 32
  • 62
0
votes
1 answer

rails mongodb find and delete duplicate

Is there a that I can make this algorithm faster? I'm fetching all documents for this Model (Artifact) and for each document I would like to know if there is duplicate and if so I delete it. Artifact.all.to_a.each do |n| image =…
Papouche Guinslyzinho
  • 5,277
  • 14
  • 58
  • 101
0
votes
1 answer

Rails 4.1 7 Mongoid Activerecord is autosaving without calling .save

Let me explain first my model structure: i have a status model: class Status include Mongoid::Document include Mongoid::Search include Mongoid::Timestamps field :status_code, type: Integer field :status_description, type: String …
0
votes
1 answer

Unable to create document in mongoid with field type array

Following is my model which has a field with type array class User::Log::Presentation include Mongoid::Document include Mongoid::Timestamps field :name, type: String field :fields, type: Array, default: [] end When I try creating a…
gak4u
  • 80
  • 1
  • 6
0
votes
1 answer

Mongoid 1-N insert duplicate key error

I'm getting a weird behaviour from Mongoid 4.0.0 and Rails 4, I have a 1-N relationship and I get a duplicate key error index when I try to save the N side of the relationship. Let me show you some code: module MyEngine class Collection …
Julien
  • 2,217
  • 2
  • 28
  • 49
0
votes
1 answer

uninitialized constant Mongoid::Slug - can't get mongoid-slug to work

Receiving uninitialized constant Mongoid::Slug when trying to load a view. The troubled Model is: class Course include Mongoid::Document include Mongoid::Timestamps include Mongoid::Slug field :title, type: String slug :title validates…
Grant Trevor
  • 1,052
  • 9
  • 23
0
votes
1 answer

ActiveJob pass BSON::ObjectId as parameter

Active job does not allow me to pass an ObjectId as a parameter, any way I can do it without converting to and from a string?
Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141
0
votes
1 answer

Getting all the post from multiple subjects

I want to show all the post which only related to all of the subject of the user. I have tried and tried but I'm always getting error. It's too confusing because it has a lot of relation for me. Here are the models. class Post include…
nsantiago2719
  • 325
  • 1
  • 3
  • 13
0
votes
0 answers

Saving the user and subject id automatically

I have this Models and if I'm going to create a post. I want to automatically save the user id and the subject id. But it's not happening what I know is it automatically store the user_id and the subject_id . Can someone explain me why and better if…
nsantiago2719
  • 325
  • 1
  • 3
  • 13
0
votes
1 answer

sidekiq mongoid 4 not working

I am working with rails4 monogid and sidekiq , I am unable to start(exec) sidekiq with the following command bundle exec sidekiq following is the stack trace wrong number of arguments (0 for…
0
votes
1 answer

How instantiate a Mongoid model with multiple belongs_to

I'm not sure how to instantiate an object that belongs to multiple objects: class Project ... belongs_to :project_lead, :class_name => 'User' has_many :users, :class_name => 'User' has_many …
WagnerMatosUK
  • 4,309
  • 7
  • 56
  • 95
0
votes
0 answers

Mongoid does not save the _type of a collection

I have here the behaviour that in one of my collection the _type field was not populated, what in my case is really needed. scenario 'User edits a session' do session = survey.sessions.create version: version, token: 'xxx' produces a database…
Markus Graf
  • 533
  • 3
  • 16
0
votes
0 answers

Can't run Rails 4 app with Mongoid

I want to use MongoDB in my rails application and facing a problem: Could not connect to a primary node for replica set #]> This is what I've done to set up my project: Created a new project with the following command, in order to replace Mongoid…
Maboo
  • 425
  • 1
  • 9
  • 18