Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MongoDB & Rails
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Amaia Castro
February 28, 2013
Programming
4
240
MongoDB & Rails
Intro to using MongoDB with Rails. Presented at Madrid-rb
Amaia Castro
February 28, 2013
Tweet
Share
Other Decks in Programming
See All in Programming
PHPで TLSのプロトコルを実装してみる
higaki_program
0
420
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
550
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
160
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
150
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
360
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
180
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
160
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
230
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.5k
モダンOBSプラグイン開発
umireon
0
180
ロボットのための工場に灯りは要らない
watany
12
3.2k
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
190
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
84
A designer walks into a library…
pauljervisheath
210
24k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
160
YesSQL, Process and Tooling at Scale
rocio
174
15k
HDC tutorial
michielstock
1
580
Navigating Team Friction
lara
192
16k
[SF Ruby Conf 2025] Rails X
palkan
2
850
Amusing Abliteration
ianozsvald
0
140
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
So, you think you're a good person
axbom
PRO
2
2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
490
Transcript
MongoDB & Rails madrid-rb
Amaia Castro Freelance Ruby on Rails developer amaiacastro.com github.com/amaia @amaiac
None
RDBMS Memcached MongoDB NoSQL SQL features scale & speed
MongoDB Dynamic queries Secondary indexes Joins Transactions Referential integrity
Document
"JSON" { name: "mongo", type: "DB" }
Collections of documents
MongoDB + Rails = Mongoid (Object-Document-Mapper) Queries Validations Callbacks Associations
Tags posts tags SQL MongoDB posts_tags ------------ post_id tag_id {
title: "MongoDB", tags: [ "mongodb", "madrid-rb", "ruby" ] } posts class Post include Mongoid:: Document field :title field :tags, type: Array end
Invoice invoice invoice_line ------------ invoice_id SQL MongoDB { invoice_number: "01",
invoice_lines: [ {...}, {...} ] }
class Invoice include Mongoid::Document field :number, type: String embeds_many :invoice_lines
end class InvoiceLine include Mongoid::Document field :description, type: String field :price, type: BigDecimal embedded_in :invoice end
Users & Groups users groups SQL MongoDB groups_users ------------ user_id
group_id { _id: "abc123", username: "amaia", groups: [ "654dbd", ... ] } { _id: "654dbd", name: "madrid- rb", users: [ "abc123", ... ] } users groups
Real Life Example
ActiveRecord + Mongoid config ├── database.yml └── mongoid.yml tip: activate
safe_mode in mongoid.yml
class PersonalProfile include Mongoid::Document field :user_id, :type => Integer field
:name, :type => String field :interests, :type => Array field :skills, :type => Array def user User.find_by_id(self.user_id) end end class User < ActiveRecord::Base def personal_profile PersonalProfile.where(user_id: self.id).first end end
• No joins or transactions at DB level • Model
your data as independent documents • Avoid referenced associations in Mongoid • Mix and match SQL and NoSQL when needed Summary
Thank you