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
MUSUBIXとは
nahisaho
0
140
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.4k
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
CSC307 Lecture 03
javiergs
PRO
1
490
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
250
AgentCoreとHuman in the Loop
har1101
5
240
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
760
CSC307 Lecture 04
javiergs
PRO
0
660
Patterns of Patterns
denyspoltorak
0
1.4k
Fluid Templating in TYPO3 14
s2b
0
130
Basic Architectures
denyspoltorak
0
680
Featured
See All Featured
BBQ
matthewcrist
89
10k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
YesSQL, Process and Tooling at Scale
rocio
174
15k
Side Projects
sachag
455
43k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
250
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
120
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
120
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
180
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