How can you sort on an assoicated EmbeddedDocument? For instance, if
I have a "Post" Document and a "Comment" EmbeddedDocument - how can I
sort the comments by "created_at".
I tried...
>> post = Post.first
>> post.comments(:order => "created_at")
...but it didn't seem to work. I'm sure I'm doing something stupid
but I can't work it out!
Thanks!
Phil
On Jan 18, 1:45 pm, Brandon Martin <bmar...@zyphmartin.com> wrote:
> Do you have
>
> timestamps!
>
> set in your model? If not there is no created_at column.
>
> Brandon
--
You received this message because you are subscribed to the Google
Groups "MongoMapper" group.
For more options, visit this group at
http://groups.google.com/group/mongomapper?hl=en?hl=en
post.comments.sort_by(&:created_at)
And get the same result. But I don't know if that would be the best
way to do it.
post.comments.sort_by(&:created_at).reverse
Thanks!
On Jan 18, 2:22 pm, Gustavo Beathyate <r...@obviamente.pe> wrote:
> I think you could do:
>
> post.comments.sort_by(&:created_at)
>
> And get the same result. But I don't know if that would be the best
> way to do it.
>