MongoMapper.database = 'catalog'
class Item
include MongoMapper::Document
key :title, String, :required => true, :index => true
key :author, String
end
And I can create new items without any problems. However, when I run
the mongo shell and type "db.items.getIndexes()" it appears that the
index for title isn't being created:
[
{
"name" : "_id_",
"ns" : "catalog.items",
"key" : {
"_id" : ObjectId("000000000000000000000000")
}
}
]
I've tried removing :required and setting it via ensure_index as well
with no luck. I'm just getting started with mongodb, so I could be
missing/misunderstanding something.
When you check in the shell are you using the right database?
Try `use catalog` before running your query.
- Mike
> --
> 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
>
Have you launch MongoMapper.ensure_index! ? without this command, no
index are created by MongoMapper.
--
Cyril Mougel
http://blog.shingara.fr/
Yep, I'm doing that. I've tried dropping the database and starting
over with no effect. I can create the index manually from the shell
via `db.bib_records.ensureIndex({'title':1})` and it shows up as you'd
expect.
--
-----Original Message-----
From: mongo...@googlegroups.com [mailto:mongo...@googlegroups.com] On Behalf Of Cyril Mougel
Sent: Friday, December 18, 2009 9:06 AM
To: mongo...@googlegroups.com
Subject: Re: [MongoMapper] Index Not Created?
Le 18/12/09 17:43, Matt a écrit :
--
On Dec 18, 11:11 am, "Nathan Stults" <Nathan_Stu...@HSIHealth.com>
wrote:
> Cyril Mougelhttp://blog.shingara.fr/