1

I'm new to rails application. I got connection with mongodb using mongoid. I generated the mongoid:migration using command called

rails generate migration sample

it creates,

db\migrate\20111222081138_sample.rb contains the following code

class Sample < Mongoid::Migration
   def self.up
      sample.create(first_name: "Heinrich", last_name: "Heine")
   end    

   def self.down
   end
end
my questions are
1.why schema.rb is not present in db.
2.how to populate data into mongodb using rails
3.how to list db collections in rails
4.how to produce bson file into rails
2
  • 1
    have you read the documentation on MongoId or MongoDB? Commented Dec 22, 2011 at 10:28
  • 1
    Migrations for mongoid? I think something is wrong here. Please check out the documentation for mongoid, mongodb and rails. As Simone pointed out, it would be better to learn one technology first. Commented Dec 22, 2011 at 15:45

2 Answers 2

7

MondoDB is a schema-less database, this is the reason why schema.rb is not present.

To query, insert, update or delete records, follow the instructions available in the Mongoid documentation. The documentation is comprehensive, well-written and it is worth a read.

Also, if you are completely new to Rails and you don't know almost anything about NoSQL databases, it's better if you start with one technology at time and you just try Rails with a relational database, such as SQLite or PostgreSQL.

The most part of Rails ORM tutorials is about ActiveRecord. Trying to approach several new topics at once just leads to confusion.

Sign up to request clarification or add additional context in comments.

Comments

0

I also encountered this problem I'm new on using rails with mongodb. The solution I found is to create db/seeds.rb manually. Add the dummy data there and run rails db:seed as usual. It works just fine for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.