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
Rails Bootcamp [Sesión 03]
Search
A. Felipe Cabargas Madrid
June 04, 2016
Programming
0
57
Rails Bootcamp [Sesión 03]
A. Felipe Cabargas Madrid
June 04, 2016
Tweet
Share
More Decks by A. Felipe Cabargas Madrid
See All by A. Felipe Cabargas Madrid
Layers Layers Layers
felipecabargas
0
55
Accesibilidad Web: Que, como, cuando y por que?
felipecabargas
0
27
Untangling git
felipecabargas
0
60
Docker 101
felipecabargas
1
80
GroupRaise Learning Fridays: UX 101
felipecabargas
0
96
GroupRaise Learning Fridays: Hows and whys of version control
felipecabargas
0
49
Sesion III - Taller RoR LCC
felipecabargas
0
87
Sesion II - Taller RoR LCC
felipecabargas
0
120
Taller RoR LCC
felipecabargas
0
140
Other Decks in Programming
See All in Programming
AI時代の認知負荷との向き合い方
optfit
0
160
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
220
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
310
CSC307 Lecture 07
javiergs
PRO
1
550
Architectural Extensions
denyspoltorak
0
290
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1k
AgentCoreとHuman in the Loop
har1101
5
240
CSC307 Lecture 10
javiergs
PRO
1
660
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
380
Featured
See All Featured
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
270
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
150
Abbi's Birthday
coloredviolet
1
4.8k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
Paper Plane (Part 1)
katiecoart
PRO
0
4.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
HDC tutorial
michielstock
1
390
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
210
Transcript
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