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
47
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
42
Accesibilidad Web: Que, como, cuando y por que?
felipecabargas
0
18
Untangling git
felipecabargas
0
54
Docker 101
felipecabargas
1
69
GroupRaise Learning Fridays: UX 101
felipecabargas
0
81
GroupRaise Learning Fridays: Hows and whys of version control
felipecabargas
0
43
Sesion III - Taller RoR LCC
felipecabargas
0
59
Sesion II - Taller RoR LCC
felipecabargas
0
100
Taller RoR LCC
felipecabargas
0
100
Other Decks in Programming
See All in Programming
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
340
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
27
8.2k
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
[技育CAMPアカデミア]アイディアを形に!【超入門】スマホアプリ開発〜リリースまでの流れをご紹介
teamlab
PRO
0
370
Code Reviews
bkuhlmann
4
890
PHPはいつから死んでいるかの調査
chiroruxx
1
400
Milestoner
bkuhlmann
1
410
エンターテイメント業界で利用されるAWS
demuyan
0
210
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
530
二郎系ラーメンのコールで学ぶ AST 解析
memory1994
PRO
7
1.7k
Netty Chicago Java User Group 2024-04-17
sullis
0
170
Rethinking UI building strategies @ SFI 2024
letelete
0
270
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
A better future with KSS
kneath
231
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
25
2.3k
Raft: Consensus for Rubyists
vanstee
132
6.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
Building Flexible Design Systems
yeseniaperezcruz
319
37k
Writing Fast Ruby
sferik
621
60k
Infographics Made Easy
chrislema
238
18k
How STYLIGHT went responsive
nonsquared
92
4.8k
Rails Girls Zürich Keynote
gr2m
91
13k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Faster Mobile Websites
deanohume
299
30k
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