Ruby and MongoDB Web Development Beginner's Guide

Ruby and MongoDB Web Development Beginner's Guide

Gautam Rege

Language: English

Pages: 332

ISBN: 2:00094763

Format: PDF / Kindle (mobi) / ePub


Create dynamic web applications by combining the power of Ruby and MongoDB

Overview
* Step-by-step instructions and practical examples to creating web applications with Ruby and MongoDB
* Learn to design the object model in a NoSQL way
* Create objects in Ruby and map them to MongoDB

In Detail

MongoDB is a high-performance, open source, schema-free document-oriented database. Ruby is an object- oriented scripting language. Ruby and MongoDB are an ideal partnership for building scalable web applications.

Ruby and MongoDB Web Development Beginner's Guide is a fast-paced, hands-on guide to get started with web application development using Ruby and MongoDB. The book follows a practical approach, using clear and step-by-step instructions and examples in Ruby to demonstrate application development using MongoDB.

The book starts by introducing the concepts of MongoDB. The book teaches everything right from the installation to creating objects, MongoDB internals, queries and Ruby Data Mappers.

You will learn how to use various Ruby data mappers like Mongoid and MongoMapper to map Ruby objects to MongoDB documents.

You will learn MongoDB features and deal with geo-spatial indexing with MongoDB and Scaling MongoDB.

With its coverage of concepts and practical examples, Ruby and MongoDB Web Development Beginner's Guide is the right choice for Ruby developers to get started with developing websites with MongoDB as the database.

What you will learn from this book
* Get MongoDB and Ruby up and running on your machine (Windows/Mac/Linux)
* Leverage MongoDB to build highly scalable data-centric applications
* Leverage MongoDB replication to ensure high availability and reliability
* Create your first object and save it to MongoDB
* Create a Ruby Object and map it to MongoDB document
* Process large datasets with MapReduce
* Create geo-spatial indexes or 2D indexes
* Learn about Mongoid and MongoMapper for mapping Ruby objects to MongoDB documents

Approach

This book is packed with step-by-step instructions and practical examples, along with accompanying screenshots and code for an easy learning curve. The needs of a beginner are totally satisfied by the book.

Who this book is written for

This book assumes that you are experienced in Ruby development skills - Ruby, HTML, CSS. Having knowledge of using NoSQL will help you get through the concepts quicker, but it is not mandatory. No prior knowledge of MongoDB required.

China’s Housing Reform and Outcomes

.net [UK] (March 2015)

Learning Windows 8 Game Development

Nuclear 2.0: Why a Green Future Needs Nuclear Power

Programming Windows 8 Apps with HTML, CSS, and JavaScript

Capitalism without Democracy: The Private Sector in Contemporary China

 

 

 

 

 

 

 

 

 

 

 

 

 

 

book!", username: "Gautam"> > b.reviews.create(comment: "Excellent literature", username: "Tom") => # What just happened? That's it—we just created reviews for books. Let's fetch them and check: b.reviews => [#, #

fetch the full results now. The following command does it for us: > results.find().to_a => [{"_id"=>"Dick", "value"=>{"rating"=>12.0}}, {"_id"=>"Gautam", "value"=>{"rating"=>21.0}}, {"_id"=>"Tom", "value"=>{"rating"=>3.0}}] What just happened? Voila! This shows that we have the following result: ‹‹ Dick has 12 ratings ‹‹ Gautam has 21 ratings ‹‹ Tom has 3 ratings Tally these ratings manually with the preceding code and verify. What would you have to do if you did not have Map/Reduce?

in each table, it could reach a temporary join of around 1 million * 1 million * 1 million entries, degrading the performance drastically. Every RDBMS is smart enough not to create such a huge temporary table of course, but the result set is still huge. ‹‹ If we consider that the data is distributed between nodes (shared), the network latency to gather information for a join from different nodes is going to be huge. These are a few reasons why the NoSQL faction shies away from joins. As we

relation has inverse_of :followers and vice versa! This is shown clearly in the following code: class Author include Mongoid::Document has_and_belongs_to_many :followers, class_name: "Author", inverse_of: :following has_and_belongs_to_many :following, class_name: "Author", inverse_of: :followers end Now, let's see the actual working of this relationship. When we set up the following for one author, we did it as follows: irb> a.following << b => [BSON::ObjectId('4ef5ab6ffed0eb89bf000001')] When

4f214bfcfed0eb863b000002, _type: nil> [ 177 ] Modeling Ruby with Mongoid This is how we can embed the same object into the document under different names using the :name option just explained. Managing changes in models What happens if we require some changes to the document schema? If this were the SQL book, I would have said that we require some way to use statements like ALTER TABLE, ADD COLUMN, CHANGE COLUMN, and so on. You would need some way to maintain the changes and, if required,

Download sample

Download