SlideShare una empresa de Scribd logo
1 de 21
Rails with MongoDB


             Kosuke Matsuda
• MongoDB
• Mac MongoDB
• Ruby MongoDB
• Rails MongoDB
MongoDB

MongoDB C++




              http://ja.wikipedia.org/wiki/MongoDB
MongoDB

•
•
•
•
•
        http://www.mongodb.org/display/DOCSJP/Home
•
    RDB

•
    RDB

•
    RDB
Mac MongoDB


•
    http://www.mongodb.org/display/DOCS/Downloads


• MacPorts
    $ sudo port install mongodb
MongoDB
$ sudo mkdir -p /opt/local/var/db/mongodb
$ sudo mkdir -p /opt/local/var/log/
$ sudo touch /opt/local/var/log/mongodb.log
$ /opt/local/bin/mongod --dbpath /opt/local/$ var/db/
mongodb --logpath /opt/local/var/log/mongodb.log
#                                     /data/db/
# Mac                 http://github.com/AndreiRailean/MongoDB-
OSX-Launchctl
Ruby MongoDB


• mongo-ruby-driver
 • Official Ruby driver for MongoDB
 •   http://github.com/mongodb/mongo-ruby-driver
Set up

$ sudo gem install mongo
# mongo gem                     BSON gem
$ sudo gem install bson

#                           C

$ sudo gem install bson_ext
Tutorial
require "rubygems"
require "mongo"

db = Mongo::Connection.new.db('test')
coll = db.collection("sample")
doc = {
  'name' => 'MongoDB',
  'type' => 'database',
  'info' => {
    'language' => 'ruby',
    'driver' => 'ruby_driver'
  }
}
coll.insert(doc)
mydoc = coll.find_one()
puts mydoc.inspect
# {"_id"=>BSON::ObjectID('4c2733f4a27a137051000001'), "name"=>"MongoDB",
"info"=>{"language"=>"ruby", "driver"=>"ruby_driver"}, "type"=>"database"}
Rails     MongDB

• O/R Mapper
 • MongoMapper
   • http://mongomapper.com/
 • Mongoid
   • http://mongoid.org/
MongoDB

• ActiveRecord
• Rails Model
• SQL-like
•
                       http://blog.madoro.org/mn/54
Set up
• Configuration for Database
  $ cat config/initializers/database.rb
  MongoMapper.database = "mongo_sample-#{Rails.env}"
  if defined?(PhusionPassenger)
   PhusionPassenger.on_event(:starting_worker_process) do |forked|
     MongoMapper.connection.connect_to_master if forked
   end
  end

  $ echo "# Using MongoDB" > config/database.yml
Set up

• Environment
  # config/environment.rb
  config.frameworks -= [ :active_record ]
  config.gem "mongo_mapper"
Demo
• $ script/generate model ‘ModelName’
•
•   Rails           Rails3



•   MongoDB NoSQL



•   RDB                      Rails
any questions?
Rails with mongodb

Más contenido relacionado

La actualidad más candente

サーバー・クライアントの ボトルネック調査と高速化
サーバー・クライアントの ボトルネック調査と高速化サーバー・クライアントの ボトルネック調査と高速化
サーバー・クライアントの ボトルネック調査と高速化
Sugawara Genki
 
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
PatrickCrompton
 

La actualidad más candente (20)

Django rest framework
Django rest frameworkDjango rest framework
Django rest framework
 
Setup ruby
Setup rubySetup ruby
Setup ruby
 
Доклад Михаила Егорова на PHDays
Доклад Михаила Егорова на PHDaysДоклад Михаила Егорова на PHDays
Доклад Михаила Егорова на PHDays
 
Front End Development Automation with Grunt
Front End Development Automation with GruntFront End Development Automation with Grunt
Front End Development Automation with Grunt
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
 
Railsで作るBFFの功罪
Railsで作るBFFの功罪Railsで作るBFFの功罪
Railsで作るBFFの功罪
 
Week6
Week6Week6
Week6
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gem
 
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
 
Bar Camp Atl3
Bar Camp Atl3Bar Camp Atl3
Bar Camp Atl3
 
Unit Testing With Javascript
Unit Testing With JavascriptUnit Testing With Javascript
Unit Testing With Javascript
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
サーバー・クライアントの ボトルネック調査と高速化
サーバー・クライアントの ボトルネック調査と高速化サーバー・クライアントの ボトルネック調査と高速化
サーバー・クライアントの ボトルネック調査と高速化
 
Production Ready Javascript With Grunt
Production Ready Javascript With GruntProduction Ready Javascript With Grunt
Production Ready Javascript With Grunt
 
Web開発の技術選び、 好き嫌いでやってませんか 〜技術選びで注目すべきポイントとは〜
Web開発の技術選び、 好き嫌いでやってませんか  〜技術選びで注目すべきポイントとは〜Web開発の技術選び、 好き嫌いでやってませんか  〜技術選びで注目すべきポイントとは〜
Web開発の技術選び、 好き嫌いでやってませんか 〜技術選びで注目すべきポイントとは〜
 
Mojolicious mvc
Mojolicious mvcMojolicious mvc
Mojolicious mvc
 
[20180226] I understand webpacker perfectly
[20180226] I understand webpacker perfectly[20180226] I understand webpacker perfectly
[20180226] I understand webpacker perfectly
 
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
 
Drupal 8 + Elasticsearch + Docker
Drupal 8 + Elasticsearch + DockerDrupal 8 + Elasticsearch + Docker
Drupal 8 + Elasticsearch + Docker
 
Bundler is the Best
Bundler is the BestBundler is the Best
Bundler is the Best
 

Similar a Rails with mongodb

Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
MongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
rfischer20
 
Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-final
MongoDB
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
Serdar Buyuktemiz
 
MongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB at Gilt Groupe
MongoDB at Gilt Groupe
MongoDB
 

Similar a Rails with mongodb (20)

Mongodb
MongodbMongodb
Mongodb
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introduction
 
Getting started with MongoDB and Scala - Open Source Bridge 2012
Getting started with MongoDB and Scala - Open Source Bridge 2012Getting started with MongoDB and Scala - Open Source Bridge 2012
Getting started with MongoDB and Scala - Open Source Bridge 2012
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHP
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-final
 
10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
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
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with Ruby
 
Spring Data MongoDB 介紹
Spring Data MongoDB 介紹Spring Data MongoDB 介紹
Spring Data MongoDB 介紹
 
Mongodb workshop
Mongodb workshopMongodb workshop
Mongodb workshop
 
MongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB at Gilt Groupe
MongoDB at Gilt Groupe
 
Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013Build your first MongoDB App in Ruby @ StrangeLoop 2013
Build your first MongoDB App in Ruby @ StrangeLoop 2013
 

Más de Kosuke Matsuda (9)

Combine
CombineCombine
Combine
 
Swift 5.1 - Property Wrapper
Swift 5.1 - Property WrapperSwift 5.1 - Property Wrapper
Swift 5.1 - Property Wrapper
 
Swift 5.1
Swift 5.1Swift 5.1
Swift 5.1
 
Build Time Analyzer
Build Time AnalyzerBuild Time Analyzer
Build Time Analyzer
 
SafeArea
SafeAreaSafeArea
SafeArea
 
URLProtocol
URLProtocolURLProtocol
URLProtocol
 
APIKit
APIKitAPIKit
APIKit
 
Core Data
Core DataCore Data
Core Data
 
GAE_20100112
GAE_20100112GAE_20100112
GAE_20100112
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Rails with mongodb

  • 1. Rails with MongoDB Kosuke Matsuda
  • 2.
  • 3. • MongoDB • Mac MongoDB • Ruby MongoDB • Rails MongoDB
  • 4. MongoDB MongoDB C++ http://ja.wikipedia.org/wiki/MongoDB
  • 5. MongoDB • • • • • http://www.mongodb.org/display/DOCSJP/Home
  • 6. RDB • RDB • RDB
  • 7. Mac MongoDB • http://www.mongodb.org/display/DOCS/Downloads • MacPorts $ sudo port install mongodb
  • 8. MongoDB $ sudo mkdir -p /opt/local/var/db/mongodb $ sudo mkdir -p /opt/local/var/log/ $ sudo touch /opt/local/var/log/mongodb.log $ /opt/local/bin/mongod --dbpath /opt/local/$ var/db/ mongodb --logpath /opt/local/var/log/mongodb.log # /data/db/ # Mac http://github.com/AndreiRailean/MongoDB- OSX-Launchctl
  • 9. Ruby MongoDB • mongo-ruby-driver • Official Ruby driver for MongoDB • http://github.com/mongodb/mongo-ruby-driver
  • 10. Set up $ sudo gem install mongo # mongo gem BSON gem $ sudo gem install bson # C $ sudo gem install bson_ext
  • 11. Tutorial require "rubygems" require "mongo" db = Mongo::Connection.new.db('test') coll = db.collection("sample") doc = { 'name' => 'MongoDB', 'type' => 'database', 'info' => { 'language' => 'ruby', 'driver' => 'ruby_driver' } } coll.insert(doc) mydoc = coll.find_one() puts mydoc.inspect # {"_id"=>BSON::ObjectID('4c2733f4a27a137051000001'), "name"=>"MongoDB", "info"=>{"language"=>"ruby", "driver"=>"ruby_driver"}, "type"=>"database"}
  • 12. Rails MongDB • O/R Mapper • MongoMapper • http://mongomapper.com/ • Mongoid • http://mongoid.org/
  • 13. MongoDB • ActiveRecord • Rails Model • SQL-like • http://blog.madoro.org/mn/54
  • 14. Set up • Configuration for Database $ cat config/initializers/database.rb MongoMapper.database = "mongo_sample-#{Rails.env}" if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| MongoMapper.connection.connect_to_master if forked end end $ echo "# Using MongoDB" > config/database.yml
  • 15. Set up • Environment # config/environment.rb config.frameworks -= [ :active_record ] config.gem "mongo_mapper"
  • 16. Demo
  • 17. • $ script/generate model ‘ModelName’
  • 18. • • Rails Rails3 • MongoDB NoSQL • RDB Rails
  • 19.

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n