Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rails Bootcamp [Sesión 03]
Search
A. Felipe Cabargas Madrid
June 04, 2016
Programming
71
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails Bootcamp [Sesión 03]
A. Felipe Cabargas Madrid
June 04, 2016
Transcript
23 slides
RAILS BOOTCAMP 3 JUNIO 2016
ACTIVERECORD
Modelos
$ rails generate model Person
/app/models/person.rb
Migraciones
/db/migrate
$ rake db:migrate
Crear modelo de datos de tu app recuerden migrar los
nuevos modelos
Jugando con la consola de rails recuerden migrar los nuevos
modelos
$ rails console
p = Person.first
p.name
Person.all
Crear asociaciones
$ rails generate migration AddReferencesToBook person:references
app/models/person.rb class Person < ActiveRecord::Base has_many :books # has_one :book
end
app/models/book.rb class Book < ActiveRecord::Base belongs_to :person end
Crear validaciones
app/models/person.rb class Person < ActiveRecord::Base validates :name, presence: true end
Callbacks
before_save after_save before_create after_create before_validation after_validation
app/models/person.rb class Person < ActiveRecord::Base before_save :count_pets def count_pets if
self.email.nil? puts "No tiene mail" else puts "Yeih! #{self.email}" end end end
More Decks by A. Felipe Cabargas Madrid
See All by A. Felipe Cabargas Madrid
Layers Layers Layers
felipecabargas
0
80
Accesibilidad Web: Que, como, cuando y por que?
felipecabargas
0
65
Untangling git
felipecabargas
0
75
Docker 101
felipecabargas
1
100
GroupRaise Learning Fridays: UX 101
felipecabargas
0
120
GroupRaise Learning Fridays: Hows and whys of version control
felipecabargas
0
67
Sesion III - Taller RoR LCC
felipecabargas
0
110
Sesion II - Taller RoR LCC
felipecabargas
0
140
Taller RoR LCC
felipecabargas
0
170
Other Decks in Programming
See All in Programming
AIコーディング時代のKotest ユニットテストから APIレベルの仕様固定化テストへ
ooga04
0
330
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
170
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
240
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
610
LLM 101
dalinaum
0
520
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
270
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
790
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
220
Spec-driven Development with AI
simas
PRO
0
2.3k
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
690
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
240
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
400
Featured
See All Featured
Practical Orchestrator
shlominoach
192
12k
WCS-LA-2024
lcolladotor
0
1k
For a Future-Friendly Web
brad_frost
184
11k
Speed Design
sergeychernyshev
33
2.2k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
We Are The Robots
honzajavorek
0
460
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
580
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520
Side Projects
sachag
456
43k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
400
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k