Reputation:
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
Upvotes: 1
Views: 1688
Reputation: 99
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.
Upvotes: 0
Reputation: 176392
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.
Upvotes: 7