Your SlideShare is downloading. ×
0
Rails with MongoDB             Kosuke Matsuda
• MongoDB• Mac MongoDB• Ruby MongoDB• Rails MongoDB
MongoDBMongoDB 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...
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...
Tutorialrequire "rubygems"require "mongo"db = Mongo::Connection.new.db(test)coll = db.collection("sample")doc = {  name =>...
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}...
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
Rails with mongodb
Rails with mongodb
Upcoming SlideShare
Loading in...5
×

Rails with mongodb

3,143

Published on

RailsでMongoDBを利用する

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,143
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
57
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Rails with mongodb"

    1. 1. Rails with MongoDB Kosuke Matsuda
    2. 2. • MongoDB• Mac MongoDB• Ruby MongoDB• Rails MongoDB
    3. 3. MongoDBMongoDB C++ http://ja.wikipedia.org/wiki/MongoDB
    4. 4. MongoDB••••• http://www.mongodb.org/display/DOCSJP/Home
    5. 5. • RDB• RDB• RDB
    6. 6. Mac MongoDB• http://www.mongodb.org/display/DOCS/Downloads• MacPorts $ sudo port install mongodb
    7. 7. 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
    8. 8. Ruby MongoDB• mongo-ruby-driver • Official Ruby driver for MongoDB • http://github.com/mongodb/mongo-ruby-driver
    9. 9. Set up$ sudo gem install mongo# mongo gem BSON gem$ sudo gem install bson# C$ sudo gem install bson_ext
    10. 10. Tutorialrequire "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"}
    11. 11. Rails MongDB• O/R Mapper • MongoMapper • http://mongomapper.com/ • Mongoid • http://mongoid.org/
    12. 12. MongoDB• ActiveRecord• Rails Model• SQL-like• http://blog.madoro.org/mn/54
    13. 13. 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
    14. 14. Set up• Environment # config/environment.rb config.frameworks -= [ :active_record ] config.gem "mongo_mapper"
    15. 15. Demo
    16. 16. • $ script/generate model ‘ModelName’
    17. 17. •• Rails Rails3• MongoDB NoSQL• RDB Rails
    18. 18. any questions?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×