Could I declare a model with a key called :key, for instance? Is there any word I can’t use for a key?
Could I declare a model with a key called :key , for instance? Is
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first question if very easy to answer yourself. Open irb and try:
No errors? I guess
keyis a valid key!As far as I know, the only keys you shouldn’t use for your own data are
_idand_type. You can use either, but they will change behavior. Using_idwill make whatever you’re setting as that key the unique id for the object. Using_typewill cause MongoMapper to try to instantiate an instance of whatever’s in your_testkey when bringing the object back from the database.