What is Mongo-DB

What is MongoDB?
I saw many forums, visited many blogs, people/programmers are talking about MongoDB a lot. I was wondering what this is! Why developers are showing more and more interest in this. I started searching around and now sharing with all of you, who are not friendly with MongoDB or who’re familiar but don’t know how to work on it.

First of all let’s define mongoDB in terms of technical aspect
a) MongoDB has collections of data, not tables.
b) Its a document-oriented database.
c) MongoDB has namespaces for data.
d) You don’t ever need to worry about migrations due to Mongo’s schema-less nature.
e) You can define indexing options too.

So far, what my learning works here that it has nothing to do with the migrations, tables. In short if I say, it is a database in a documented form, a separate entity as compared to MySQL or different databases, am I wrong?

Ok, try to put your brain to understand this, because from here I will try to cover some real world examples to explain how it works… :)

How to install MongoDB
A) gem install mongo
It will install mongo with bson.. something like this screenshot

B) gem install mongo_mapper

I think, these two gems are sufficient to give you some kind of acceleration. Let’s proceed further and create a model, fire this command
C) ruby script/generate model Book –skip-migration

D) Let’s enter some fields into it, as I said it has nothing to do with the migration, so what are the columns that we want, we will create here itself, See how:

Rails 3, Its here!!

In these days lots of people are talking about RAILS 3, the biggest and most happening version as compared with the previous ones. There are many changes in each and every part of the application.

Here, we will cover the changes, dependencies, how we install rails 3 on windows and linux and a basic sample RAILS 3 application..

So Here we go:
1st We will install rails 3 on windows.
Note: To Install rails 3, you must be having ruby-1.8.7 or higher, So If you’re running with ruby-1.8.6, it’s time to upgrade now.
To do that download the executable version of ruby(either 1.8.7 or 1.9.1) click here and download Ruby 1.9.1-p378 (RC2). Once done run the setup and check both the option as per the below image.

Once done with the installation, You need to copy 3 DLL files under /Ruby19/bin folder and these files are:
1. readline.dll (Download from here)
2. ssleay32.dll (Download from here)
3. zlib.dll (Download from here)
4. OpenSSL(Download from Here)
For better examples, you can also refer UKNatureBlog

Once you copied all the dependencies, now it’s time to start few gems, which will help us to install rails 3.0.
Do update your system with this:
gem update –system
Because bundler and i18n looks for rubygem >= 1.3.6
To install these gems, open up command prompt and type:
gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n

and you’ll find progress something like this:

You have to install rack as well in order to install rails 3. To do that type:
gem install rack
Once done with it, now its time to install rails 3.0, so do this:
gem install rails –pre

Note: Don’t worry if your installation fails somewhere in the middle. Important is your gems(like activerecord, activeresource etc.) should be installed successfully, no matter ri and rdoc encounters an error.

So far we’ve installed ruby-1.9 and rails-3.0. Now it’s time to create your first rails application. Here I am assuming that you already have mysql installed in your system. So open up your command prompt and fire this command.
rails myrails3_app -J -d mysql
and you’ll see progress like this:

Other possible parameters:
1. –skip-activerecord

Now let’s look at the directory structure which rails-3.0 has created for us:

At first glance you will notice that, there is no change in the directory structure, everything is the same (except for two files config.ru and Gemfile).

We will create a sample RAILS 3 Application in our next tutorial soon.