I am just starting a new Rails 3 project using Mongoid ORM for MongoDB. There is just one thing I can not get my head around, and that is how to effectively have a many-to-many relationship. Now there is a good chance that I may be approaching this problem wrong, but as far as I know, there is at least two containers in my project that...
There are two classes:
class Person
include Mongoid::Document
field :name
embeds_many :addresses
end
class Address
include Mongoid::Document
field :city
field :street
validates_presence_of :city, :street
end
We can see, we have validated the city and street should be present.
But see following code:
person = Person...
I'm using pickle 0.3.0 with rails, cucumber and mongoid. I do found that pickle0.3.0 automatically finds the ORM. But while I wrote a cucumber scenario and tested it, It didn't find any pickle steps. Here is the sample:
Scenario: logging in user
Given the following users exists
|name|
|John|
|white|
But didn't find pickle ste...
Im having a problem transferring an SQLlite Rails 3 app over to a Mongoid Rails 3 app. In the SQLlite version, I am easily able to include an image upload form (using Paperclip) from one model ('image') within a nested form from another model ('product'). Here's my 'new' product form:
<%= form_for @product, :html => {:multipart => t...
Is there an easy way to get all attributes of a Mongoid document, including those of embedded documents?
For example, if I have the following documents:
class Person
include Mongoid::Document
embeds_many :phone_numbers
field :name
end
class PhoneNumner
include Mongoid::Document
embedded_in :person, :inverse_of => :phone_numb...
I want to port a social network to Mongoid. The join table between friends is very large. Is there any way for Mongoid to handle this join table out of the box? I've seen a couple of in-model roll-your-own solutions to it, but nothing the looks efficient. Is there a way to handle this? Or is this a case where I shouldn't be using Mo...
Hello frens..
I am having problem updating the embedded documents in mongodb.
I have a following scenario.
A User model has address as the embedded docs.
I am able to embed the address to the parent model ie; User model but i still cant figure out how to update the address embedded even though i have the _id of the address embedded
Plea...
Hello frens,
I have a problem with referenced_many and referenced_in relation model.
My model is of following.
Student references_many mobile_numbers
MobileNumber referenced_in Student
Now when i try to do
@mobile = MobileNumber.first
@mobile.student
It pops error saying
Document not found for class Student with id(s) 4c47e74ff1936f05f...
I'm new to Mongo DB and Mongoid (and still kinda new to Ruby on Rails). Since Ryan Bates dosen't happen to have a Mongoid Railscast, I need pointers to other good tutorials/screencasts.
Thanks!
...
hello frens.
I have the following validates_associated scenario
class Parent
include Mongoid::Document
validates_associated :son
validates_associated :daughter
end
when i create a parent, either of son or daughter is only created not both.
Now my problem is, when i try to create parent with son, then validation fails due to daug...
Hello Mongo Friends,
I'm starting off with a small Rails3:MongoDB:Mongoid project and came along some questions that's nature is more architectural.
When to use nested resources, and how deep to nest?
I'm not a friend of nested routes at all, but they become handy if not stacked deeper than 2 resources and document oriented database...
I've problem with mongoid and model translations. When I'm trying use mongoDB on my model I haven't idea to translate attributes and model name. It's normally in *.yml files but in this time this doesn't work. Any ideas?
...
class Person
include Mongoid::Document
field :name
embeds_many :addresses
end
class Company
include Mongoid::Document
field :name
embeds_many :addresses
end
class Address
include Mongoid::Document
embedded_in :addressable, inverse_of :addresses
end
I tried something like this
company = Company.first
person = Person.f...
I was wondering if there was a way to trigger the after_save callback on an embedded_in object in Mongoid mapper.
Example:
i = Image.new(:file => file)
user.images << i
# => i.after_save should be triggered here
I'm aware that if I call i.save after words, it will fire, however really hard to remember to do that throughout my code.
...
hello frens
why mongoid dosen't insert id when calling new on an association, but inserts id when calling build on an association?
Is this a bug or this is how it works in mongoid?
...
Attempting to start the WEBrick server on a Rails 3 / Ruby 1.9.1 with Mongoid errors with:
"MongoDB 1.4.0 not supported, please
upgrade to 1.6.0
(Mongoid::Errors::UnsupportedVersion)"
... but mongo --version:
MongoDB shell version: 1.6.1
Anyone else seen this?
Pretty new to Ruby so apologies if I'm asking a stupid questi...
I have code like this in a Rails 3 app I'm working on
<% @positions.each do |position| %>
<tr class="<%= cycle("", "alternate") %>">
<td><%= position.name %></td>
<td class="actions">
<%=link_to 'edit', edit_position_path(position), :class => 'edit' %> |
<%=link_to 'delete', position_path...
Hello all,
I'm pretty new to rails and mongoid and I have a problem with extracting a string out of a query.
I have a class Filteroption
class Fieldoption
include Mongoid::Document
field :name, :type => String
field :option_id, :type => Integer
end
and with this entries
+--------------------------+-------------...
I have stumbled upon Mongoid which has great documentation: http://mongoid.org/docs/associations/
But I have heard that MongomMapper is de-facto for Rails.
Where do I find API documentation for using Mongomapper?
...
Hello all,
I just began using Mongoid last week. I am running into this association problem which I am unsure if my approach is correct. So i thought I would ask for some opinion
I have a User model and a Project model
class User
include Mongoid::Document
field :email
end
class Project
include Mongo...