Every repository with this icon (
Every repository with this icon (
| Description: | Awesome gem for modeling your domain and storing it in mongo edit |
-
I'd like to do something like named scopes. Doesn't have to be as complex up front but this paired with a default_scope would knock out 4 or 5 of the existing tickets.
Comments
-
@doc = Document.new @doc_copy = @doc.dup @doc.title = "changed" @doc_copy == @doc # => true # According to Ruby conventions and common sense, # the answer should be false.There is a long-winded, somewhat out of control discussion here:
http://groups.google.com/group/mongomapper/browse_thread/thread/85af8026a2dba34d
Comments
jnunemaker
Thu Oct 22 21:17:26 -0700 2009
| link
Haha. "out of control". To be fare, you did start it... :) Do you have a patch example of what you are thinking?
Here's my patch from the mailing list:
http://github.com/djsun/mongomapper/tree/equality(maybe it got buried? haha)
To be fair about it, ActiveRecord doesn't get this right either:
http://djwonk.com/blog/2009/10/21/broken-equality-in-mongomapperDataMapper does get it right, perhaps MongoMapper can borrow some ideas from it?
-
This would be useful to keep logic in the most relevant place, especially when the document is embedded in multiple models.
I don't know how hard this would be to implement. I looked into it a bit, but I don't know how to access the parent of the embedded document. Is this something you are interested in?
Comments
I think it'd be great if mongomapper supported callbacks on embedded documents, +1.
The Hashrocket fork of mongomapper allows embedded documents to access their parent document but it doesn't support callbacks on embedded documents...yet.It looks like andrewtimberlake's branch just added before_save functionality.
I just added complete callback support for embedded docs in my fork:
http://github.com/zef/mongomapperI'll make a pull request soon.
jnunemaker
Wed Sep 30 20:45:28 -0700 2009
| link
Awesome! I'll try to pull in the hashrocket fork and take a look at yours soon (zef).
the fork doesn't works now.
There are some plan to implement it ?
I've been meaning to update it to work with the current version.
Are there any thoughts you have about this John?
For me the callback in embedded document is the must important features needed.
MongoId has it :(
jnunemaker
Mon Nov 16 21:46:53 -0800 2009
| link
Then use mongoid or patch away. I haven't found a clean solution from any of the submissions and don't currently need it. If I don't need it it is hard for me to champion a solution as I don't know the best way to do it.
-
Allow serializing to_xml just like ActiveRecord
0 comments Created 5 months ago by jnunemakerFor example, you can see the JSON serialization (which was mostly ported from AR).
Comments
-
When using Rails' fancy partial rending, Action View doesn't think that a mongo association is an Array.
When I use:
<%= render @list.items %>I get:
Missing template arrays/_array.erb in view path app/viewsInternally, Action View uses the case comparison operator to compare if the argument is an array (
Array === arg), which apparently returns false for an association:>> Array === [] => true >> Array === List.first.items => falseComments
-
ActionView's
date_select,datetime_select, etc. rely on ActiveRecord's multi-parameter attribute assignment, e.g.:topic.attributes = { "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31" }MongoMapper doesn't support this yet, and this is something I'd like to have at the moment, so I'm going to have a go at implementing it.
Comments
-
I'm not going to work on this for a while but if anyone wants to start working on it, feel free.
Comments
dansimpson
Wed Oct 14 15:41:45 -0700 2009
| link
I will soon deploy a rails app running ruby 1.9 and the only gem dependencies are yajl, mongo, and mongomapper. I will fork and get the tests working with 1.9 in the next 45 days.
travisbell
Wed Oct 21 13:39:04 -0700 2009
| link
I'd love to see it… I myself am hoping to deploy an app I am working on with Ruby 1.9, and mongomapper is the only gem that is not compatible with it yet.
My fork, which can be found at jpbougie/mongomapper has most of the tests passing on ruby 1.9.1. The only tests currently failing are:
- the Date#parse method now uses the international format, not the american one, so month and day are inverted.
- the error thrown while trying to mutate a frozen object is now RuntimeError, from TypeError
These are more issues with tests than about 1.9 compatibility, but they are gotchas that should be advertised.
What I had to do:
- The BasicObject you use is not so blank, at least not compared to Ruby 1.9's, which created the nasty stack overflows. I've replaced all the uses of the few methods that you had left in your basic object by equivalent ones outside the object (using Module.instance_methods instead of Class#methods, removed the #extend in favor of some metaclass instance_eval trickery)
- String#to_a no longer exists in ruby 1.9, you have to do String#lines.to_a to get the same effect
- the #methods and .instance_methods methods return an array of symbols instead of an array of string
- const_defined? and const_get have new scope lookup rules, you have to add a second argument set to false to get the old behavior
-
The dirty capability is available only in MongoMapper::Document.
I add capability to dirty in MongoMapper::EmbeddedDocument too.
My patch is on http://github.com/shingara/mongomapper/commit/bee324b44259c2f4759337da8fed058f206bc543
Any feedback are welcome.
Comments
-
When a model belongs_to embedded model (EmbeddedDocument), MongoMapper throws
class Comment include MongoMapper::EmbeddedDocument { ... } end class Video include MongoMapper::Document { ... } key :comment_id belongs_to :comment end # => video.comment undefined method `find_by_id' for Comment:ClassComments
jnunemaker
Tue Nov 24 07:38:17 -0800 2009
| link
I don't know modeling it this way is a good idea. If something is going to belong to something else, it really should be a full fledged document. Why not just store the video id in the comment?
-
reload should reset the document rather than return a new document
0 comments Created about 5 hours ago by michaeldwanReload returns a new document which is different than the ActiveRecord behavior of resetting the current object.
Looking at the tests, the convention with MM is to do:
doc = @document.create(:phrase => 'Foo') doc = doc.reload doc.changed?.should be_falseI propose we change it to be more ActiveRecord like:
doc = @document.create(:phrase => 'Foo') doc.reload doc.changed?.should be_falseI'll be adding support for that in my fork and send out a pull request soon.
Comments












If you need any inspiration for scopes, check out SearchLogic:
http://github.com/binarylogic/searchlogic/tree/master
Some nice, clean code in there :)
Also, DataMapper's implementation (infinitely chainable #all) would be really sweet.
Yeah I'm plus +1 on a more datamapper style. it's much more flexible. basically lazy queries with kicker methods
+1 on a more datamapper style too