Printing of dates from database (MongoDB)

Hello there, I'm trying to make a simple script for statement dates from MongoDB, but unfortunately, so far without the success result.

My Gemfile looks follow:

in a MongoDB is following record: --------------------------- { "_id" : ObjectId("4d715abad3d8493475000003"), "name" : "John Smith" }

I don't know, what I missed, where is a bug or what is wrong... I studied it a whole afternoon, but I can't to get the result into my view (index.html.erb)... Can me something help with this, please?

So what happens? Does Test.all return the record in question?

Fred

Hi Fred, Test.all should return this one record, but in my script nothing.

This part of code:

<%@xxx.each do |ttest|%>   <li><%=ttest.name%></li> <%end%>

Does not list any record... and I am trying to find, why... thanks

So I heard a million of tutorials and still nothing. Everything I've the right set up, but the printing dates from collection I can't to get... For example, my setup is the same as here (http://blog.futureshock-ed.com/2010/07/mongomapper-with-rails-3.html), data in my database are saved (I see that via console), but through the script is not possible to show that...

No message, no error, nothing...

Do you everybody some idea, what would be wrong? It makes me crazy...

Thanks for whatever ideas or hints!

So I heard a million of tutorials and still nothing. Everything I've the right set up, but the printing dates from collection I can't to get... For example, my setup is the same as here (http://blog.futureshock-ed.com/2010/07/mongomapper-with-rails-3.html), data in my database are saved (I see that via console), but through the script is not possible to show that...

So at the rails console, what does Test.all returns? is your record actually in the right database/collection?

Fred

Frederick Cheung wrote in post #985716:

mongo.rb --------- MongoMapper.database = "mydb"

And the dates are stored in "mydb" database in a collection called "people". And if I see on my code, I am not see the setup of collection "people", where are stored dates... So the problem could be perhaps here... but in tutorials I am not see specific the collection, from they show data...

Or the names of models, controllers and the collections must be the same?

If the model is called Testt then mongomapper will assume that the collection is called testt (although I'm sure there is a way to override that), much like how activerecord derives the table name from the class name If you renamed your class to Person, mongomapper should use the people collection automatically. Controller name is unimportant

Fred

Thanks Fred, you're my hero! Now it works :slight_smile: