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: --------------------- require ''rubygems'' require ''mongo'' source ''http://rubygems.org'' gem ''rails'', ''3.0.5'' gem "mongo_mapper" gem "rails3-generators" in config/initializers/mongo.rb: -------------------------- MongoMapper.connection = Mongo::Connection.new(''localhost'', 27017) MongoMapper.database = "justatest-development" if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| MongoMapper.connection.connect_to_master if forked end end Controller (test_controller.rb): --------- class TestController < ApplicationController def index @xxx=Test.all end end Model (test.rb) ------------ class Test include MongoMapper::Document key :name end and View (index.html.erb) -------------------- <h1>Test#index</h1> <p>Find me in app/views/test/index.html.erb</p> <ul> <%@xxx.each do |ttest|%> <li><%=ttest.name%></li> <%end%> </ul> 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? Million times, thank you! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 5, 8:34 pm, Manny 777 <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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> Million times, thank you! > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 6, 1:45 am, Manny 777 <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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> No message, no error, nothing... > > Do you everybody some idea, what would be wrong? It makes me crazy... > > Thanks for whatever ideas or hints! > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote in post #985716:> On Mar 6, 1:45am, Manny 777 <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > So at the rails console, what does Test.all returns? is your record > actually in the right database/collection? > > FredHmm...maybe here could be the problem, because I don''t know, how to specific collection, from which I want to showing dates... Current situation: controller -------- class TestController < ApplicationController def index @tests=Testt.all end end model ----- class Testt include MongoMapper::Document key :name, String end 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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 6, 11:01 am, Manny 777 <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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> > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Fred, you''re my hero! Now it works :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.