SlideShare a Scribd company logo
1 of 45
Download to read offline
Rails.loves?(:mongodb) => true
A Peek Into Making Awesomely Dynamic
Applications
How Many Have
Experience With Rails?
How Many Have
Experience With
Databases?
How Many Have Heard
Of MongoDB?
MongoDB Is...
Document database (NoSql) (1)
Data is stored as BSON Objects (looks exactly like
JSON)
Gives high performance, high availability, and easy
scalability
Gives you ultimate flexibility with features like...
Sweet Data Types: Hashes and Arrays
Allows you to nest documents
Allows for dynamic document attributes
(1) Despite the word “NoSql” you can still create a relational database with MongoDB
MongoDB In Relational Terms
MongoDB

MySql

Document

Row

Collection

Table

Database

Database

Index

Index
More MongoDB Knowledge
Two types of relations:
Embedded and Referenced
No such thing as a “join”, this type of thing can be
achieved with embedded documents and linking
Has a built in aggregation framework and map
reducing support.
You still have 1-1, 1-n, n-n relations
What A MongoDB Documents Look Like
How Does Rails Talk To MongoDB?
Mongoid - A Object-DocumentMapper(ODM) (1)

(1) There are other ODM’s out there for MongoDB, MongoMapper for example. I feel Mongoid is
far and away the best one. Has a supportive and active maintainer named Durran Jordan.
Why Not Use ActiveRecord?
ActiveRecord does not have built in
support for MongoDB. Mongoid replaces
it.
However, it still uses ActiveModel. You
still have all the validation goodness.
Getting Started
Install MongoDB...Kind of important
Mac: 









Windows:

http:/
/docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/

Ubuntu:

http:/
/docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
Getting Started With Rails
Generate a new Rails 4 Application
Modify Your Gemfile
Add the following to your gemfile, then
bundle (1)(2)

(1) Current public release of Mongoid doesn’t support Rails 4. To install Mongoid 4.0, point the
gem to the Mongoid github project.
!
(2) If your using Rails 3, use the public gem
Generate A Mongoid Configuration File
What mongoid.yml Looks Like
All Setup. What Kind of App Should We Make?

Let’s build an app that helps you track
video game achievements that you
completed.
What Models Do We Need To Create?
system: name, short_name
game: title, description, released_at,
completed_at
achievement: title, description, points,
multiplayer, completed_at
Let’s Build A Model
Use the Rails generator as normal.
What The Model Looks Like By Default

Clean model just includes Mongoid::Document to a class.
Lets Add Some Fields

In ActiveRecord you use migrations to add and remove
fields from tables.
In Mongoid you declare your fields right in the model class.
How About Some Validation
Lets Make Some Relations
The Game Model
The Achievement Model
Lets Review What We Just Did
Generated our models
Added the fields
Added validation
Made the relations
Let’s Have Some Fun in Console
Create A System

Validation works

Document Created
Create A Game For Our System
How About Another Game
Let’s Create An Achievement
How About A Multiplayer Achievement
So How Do These Look Stored In The Database?
How Do The Embedded Documents Look?
We Completed One Of Those Achievements, lets update it
Lets Store A Dynamic Field
Lets Review What We Just Did
We created a system called “Xbox One”.
We created a new game via our system document,
automatically creating the relation to system.
We created a new game, then created the relation to system.
We can find documents by providing the document ID.
Created a single and multiplayer achievement for a game.
Took a look and how these are stored in the database.
Updated one of the achievements as completed.
Updated a document with a dynamic field.
Let’s Try Some Queries
How about all the games that are completed?
How About All Games Who have Achievements With Points
Greater than 10?
How About Achievements In A Game With Points Bet ween
10 And 30
Some More Advanced Things You Can Do
Custom Validation Methods
Callbacks
Scoping
GeoNear Queries
Map Reducing
Aggregation
Obser vers
Some Resources
MongoDB.org - More information about
MongoDB
RubyonRails.org - Read up on Rails 4
Mongoid.org - Documentation for
Mongoid
Follow Me
Github - BillWatts
Twitter - @BillWatts
Thank You!
Get This Project @ http:/
/github.com/
BillWatts/rails_loves_mongodb_talk
Any Questions?

More Related Content

Viewers also liked

Editors' Session, Advanced Study Institute, HK University of Science & Techno...
Editors' Session, Advanced Study Institute, HK University of Science & Techno...Editors' Session, Advanced Study Institute, HK University of Science & Techno...
Editors' Session, Advanced Study Institute, HK University of Science & Techno...Manolis Antonoyiannakis
 
Uso de las redes sociales con fines académicos
Uso de las redes sociales con fines académicosUso de las redes sociales con fines académicos
Uso de las redes sociales con fines académicosHannyparedes
 
Anatomical positions
Anatomical positionsAnatomical positions
Anatomical positionstrieducation
 
Топография и строение шкур
Топография и строение шкурТопография и строение шкур
Топография и строение шкурqwer78
 
Customer onboarding in Banks
Customer onboarding in BanksCustomer onboarding in Banks
Customer onboarding in Banksanuppresentations
 
Poema Epico-La Odisea-Homero: Garby Farez
Poema Epico-La Odisea-Homero: Garby FarezPoema Epico-La Odisea-Homero: Garby Farez
Poema Epico-La Odisea-Homero: Garby Farez0981429035
 

Viewers also liked (8)

Editors' Session, Advanced Study Institute, HK University of Science & Techno...
Editors' Session, Advanced Study Institute, HK University of Science & Techno...Editors' Session, Advanced Study Institute, HK University of Science & Techno...
Editors' Session, Advanced Study Institute, HK University of Science & Techno...
 
պոսեյդոն
պոսեյդոնպոսեյդոն
պոսեյդոն
 
Uso de las redes sociales con fines académicos
Uso de las redes sociales con fines académicosUso de las redes sociales con fines académicos
Uso de las redes sociales con fines académicos
 
Anatomical positions
Anatomical positionsAnatomical positions
Anatomical positions
 
Топография и строение шкур
Топография и строение шкурТопография и строение шкур
Топография и строение шкур
 
Customer onboarding in Banks
Customer onboarding in BanksCustomer onboarding in Banks
Customer onboarding in Banks
 
Poema Epico-La Odisea-Homero: Garby Farez
Poema Epico-La Odisea-Homero: Garby FarezPoema Epico-La Odisea-Homero: Garby Farez
Poema Epico-La Odisea-Homero: Garby Farez
 
Diseño pedagogia-rocio
Diseño pedagogia-rocioDiseño pedagogia-rocio
Diseño pedagogia-rocio
 

Similar to Rails Loves MongoDB

MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentationHyphen Call
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Railsrfischer20
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialPHP Support
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDBNorberto Leite
 
Migrating from MySQL to MongoDB at Wordnik
Migrating from MySQL to MongoDB at WordnikMigrating from MySQL to MongoDB at Wordnik
Migrating from MySQL to MongoDB at WordnikTony Tam
 
From MySQL to MongoDB at Wordnik (Tony Tam)
From MySQL to MongoDB at Wordnik (Tony Tam)From MySQL to MongoDB at Wordnik (Tony Tam)
From MySQL to MongoDB at Wordnik (Tony Tam)MongoSF
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesAndrás Fehér
 
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...Daniel M. Farrell
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB Habilelabs
 
MongoDC - Ikanow April 2012 Meetup
MongoDC - Ikanow April 2012 MeetupMongoDC - Ikanow April 2012 Meetup
MongoDC - Ikanow April 2012 Meetupikanow
 
The Internet as a Single Database
The Internet as a Single DatabaseThe Internet as a Single Database
The Internet as a Single DatabaseDatafiniti
 
MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling Sachin Bhosale
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptxSurya937648
 
Mdb dn 2016_07_elastic_search
Mdb dn 2016_07_elastic_searchMdb dn 2016_07_elastic_search
Mdb dn 2016_07_elastic_searchDaniel M. Farrell
 

Similar to Rails Loves MongoDB (20)

MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
Experiment no 1
Experiment no 1Experiment no 1
Experiment no 1
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Mongo db report
Mongo db reportMongo db report
Mongo db report
 
Migrating from MySQL to MongoDB at Wordnik
Migrating from MySQL to MongoDB at WordnikMigrating from MySQL to MongoDB at Wordnik
Migrating from MySQL to MongoDB at Wordnik
 
From MySQL to MongoDB at Wordnik (Tony Tam)
From MySQL to MongoDB at Wordnik (Tony Tam)From MySQL to MongoDB at Wordnik (Tony Tam)
From MySQL to MongoDB at Wordnik (Tony Tam)
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 Minutes
 
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...
MongoDB Developer's Notebook, March 2016 -- MongoDB Connector for Business In...
 
Mongodb
MongodbMongodb
Mongodb
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
MongoDC - Ikanow April 2012 Meetup
MongoDC - Ikanow April 2012 MeetupMongoDC - Ikanow April 2012 Meetup
MongoDC - Ikanow April 2012 Meetup
 
The Internet as a Single Database
The Internet as a Single DatabaseThe Internet as a Single Database
The Internet as a Single Database
 
MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling
 
XCode8.0
XCode8.0XCode8.0
XCode8.0
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 
Mdb dn 2016_07_elastic_search
Mdb dn 2016_07_elastic_searchMdb dn 2016_07_elastic_search
Mdb dn 2016_07_elastic_search
 

Recently uploaded

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Rails Loves MongoDB

  • 1. Rails.loves?(:mongodb) => true A Peek Into Making Awesomely Dynamic Applications
  • 3. How Many Have Experience With Databases?
  • 4. How Many Have Heard Of MongoDB?
  • 5. MongoDB Is... Document database (NoSql) (1) Data is stored as BSON Objects (looks exactly like JSON) Gives high performance, high availability, and easy scalability Gives you ultimate flexibility with features like... Sweet Data Types: Hashes and Arrays Allows you to nest documents Allows for dynamic document attributes (1) Despite the word “NoSql” you can still create a relational database with MongoDB
  • 6. MongoDB In Relational Terms MongoDB MySql Document Row Collection Table Database Database Index Index
  • 7. More MongoDB Knowledge Two types of relations: Embedded and Referenced No such thing as a “join”, this type of thing can be achieved with embedded documents and linking Has a built in aggregation framework and map reducing support. You still have 1-1, 1-n, n-n relations
  • 8. What A MongoDB Documents Look Like
  • 9. How Does Rails Talk To MongoDB? Mongoid - A Object-DocumentMapper(ODM) (1) (1) There are other ODM’s out there for MongoDB, MongoMapper for example. I feel Mongoid is far and away the best one. Has a supportive and active maintainer named Durran Jordan.
  • 10. Why Not Use ActiveRecord? ActiveRecord does not have built in support for MongoDB. Mongoid replaces it. However, it still uses ActiveModel. You still have all the validation goodness.
  • 11. Getting Started Install MongoDB...Kind of important Mac: 
 
 
 
 
 Windows:
 http:/ /docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/ Ubuntu:
 http:/ /docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
  • 12. Getting Started With Rails Generate a new Rails 4 Application
  • 13. Modify Your Gemfile Add the following to your gemfile, then bundle (1)(2) (1) Current public release of Mongoid doesn’t support Rails 4. To install Mongoid 4.0, point the gem to the Mongoid github project. ! (2) If your using Rails 3, use the public gem
  • 14. Generate A Mongoid Configuration File
  • 16. All Setup. What Kind of App Should We Make? Let’s build an app that helps you track video game achievements that you completed.
  • 17. What Models Do We Need To Create? system: name, short_name game: title, description, released_at, completed_at achievement: title, description, points, multiplayer, completed_at
  • 18. Let’s Build A Model Use the Rails generator as normal.
  • 19. What The Model Looks Like By Default Clean model just includes Mongoid::Document to a class.
  • 20. Lets Add Some Fields In ActiveRecord you use migrations to add and remove fields from tables. In Mongoid you declare your fields right in the model class.
  • 21. How About Some Validation
  • 22. Lets Make Some Relations
  • 25. Lets Review What We Just Did Generated our models Added the fields Added validation Made the relations
  • 26. Let’s Have Some Fun in Console
  • 27. Create A System Validation works Document Created
  • 28. Create A Game For Our System
  • 30. Let’s Create An Achievement
  • 31. How About A Multiplayer Achievement
  • 32. So How Do These Look Stored In The Database?
  • 33. How Do The Embedded Documents Look?
  • 34. We Completed One Of Those Achievements, lets update it
  • 35. Lets Store A Dynamic Field
  • 36. Lets Review What We Just Did We created a system called “Xbox One”. We created a new game via our system document, automatically creating the relation to system. We created a new game, then created the relation to system. We can find documents by providing the document ID. Created a single and multiplayer achievement for a game. Took a look and how these are stored in the database. Updated one of the achievements as completed. Updated a document with a dynamic field.
  • 37. Let’s Try Some Queries
  • 38. How about all the games that are completed?
  • 39. How About All Games Who have Achievements With Points Greater than 10?
  • 40. How About Achievements In A Game With Points Bet ween 10 And 30
  • 41. Some More Advanced Things You Can Do Custom Validation Methods Callbacks Scoping GeoNear Queries Map Reducing Aggregation Obser vers
  • 42. Some Resources MongoDB.org - More information about MongoDB RubyonRails.org - Read up on Rails 4 Mongoid.org - Documentation for Mongoid
  • 43. Follow Me Github - BillWatts Twitter - @BillWatts
  • 44. Thank You! Get This Project @ http:/ /github.com/ BillWatts/rails_loves_mongodb_talk