Your SlideShare is downloading. ×
  • Like
Rails with mongodb
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Rails with mongodb

  • 3,087 views
Published

RailsでMongoDBを利用する

RailsでMongoDBを利用する

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,087
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
57
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    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

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