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 Validation Basic
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
HeChien Hsu
September 04, 2012
Technology
1
87
[教育訓練] Rails Validation Basic
HeChien Hsu
September 04, 2012
Tweet
Share
More Decks by HeChien Hsu
See All by HeChien Hsu
Using Git hosting
hechien
0
48
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
170
[Wheel Lab #2] Apple Service with Rails.
hechien
0
86
[Sokoos][教育訓練] Git - 1
hechien
0
160
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
120
[作業] 創意美學
hechien
0
62
[教育訓練] Rails Form Basic
hechien
1
77
Rails Layout Basic
hechien
2
130
Other Decks in Technology
See All in Technology
A Casual Introduction to RISC-V
omasanori
0
490
_Architecture_Modernization_から学ぶ現状理解から設計への道のり.pdf
satohjohn
2
310
VLAモデル構築のための AIロボット向け模倣学習キット
kmatsuiugo
0
300
大規模ECサイトのあるバッチのパフォーマンスを改善するために僕たちのチームがしてきたこと
panda_program
1
290
生成AIで速度と品質を両立する、QAエンジニア・開発者連携のAI協調型テストプロセス
shota_kusaba
0
290
(Test) ai-meetup slide creation
oikon48
3
470
VPCエンドポイント意外とお金かかるなぁ。せや、共有したろ!
tommy0124
1
710
ソフトバンク流!プラットフォームエンジニアリング実現へのアプローチ
sbtechnight
1
230
開発チームとQAエンジニアの新しい協業モデル -年末調整開発チームで実践する【QAリード施策】-
kaomi_wombat
0
160
Go標準パッケージのI/O処理をながめる
matumoto
0
250
コンテキスト・ハーネスエンジニアリングの現在
hirosatogamo
PRO
6
630
Goのerror型がシンプルであることの恩恵について理解する
yamatai1212
1
270
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
87
Evolving SEO for Evolving Search Engines
ryanjones
0
160
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Believing is Seeing
oripsolob
1
88
Unsuck your backbone
ammeep
672
58k
Done Done
chrislema
186
16k
Un-Boring Meetings
codingconduct
0
230
My Coaching Mixtape
mlcsv
0
80
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Abbi's Birthday
coloredviolet
2
5.5k
Transcript
Rails Validation 徐赫謙
Rails Validation Basic
會經過驗證的 • create • create! • save • save! •
update • update_attributes • update_attributes!
注意 • 有驚嘆號的(save!)驗證失敗會丟例外 • 沒驚嘆號的驗證失敗會回傳 • false: save, update_attributes •
物件: create, update
不會經過驗證的 decrement! • decrement_counter • increment! • increment_counter • toggle!
• touch • update_all • update_attribute • update_column • update_counters
⼿手動跟驗證說掰掰 save({validate: false})
Demo https://gist.github.com/3508269#file_02_demo.rb
valid? invalid? https://gist.github.com/3508269#file_01_valid_invalid.rb
errors[] https://gist.github.com/3508269#file_01_valid_invalid.rb
helpers • acceptance • confirmation • exclusion • format •
uniqueness • inclusion • length • numericality • presence • size • validates_associated
Example https://gist.github.com/3508269#file_04_demo.rb