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
HeChien Hsu
September 04, 2012
Technology
1
78
[教育訓練] 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
43
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
160
[Wheel Lab #2] Apple Service with Rails.
hechien
0
73
[Sokoos][教育訓練] Git - 1
hechien
0
150
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
110
[作業] 創意美學
hechien
0
51
[教育訓練] Rails Form Basic
hechien
1
67
Rails Layout Basic
hechien
2
120
Other Decks in Technology
See All in Technology
ガバクラのAWS長期継続割引 ~次の4/1に慌てないために~
hamijay_cloud
1
370
読んで学ぶ Amplify Gen2 / Amplify と CDK の関係を紐解く #jawsug_tokyo
tacck
PRO
1
250
SDカードフォレンジック
su3158
1
640
AIでめっちゃ便利になったけど、結局みんなで学ぶよねっていう話
kakehashi
PRO
1
380
Рекомендации с нуля: как мы в Lamoda превратили главную страницу в ключевую точку входа для персонализированного шоппинга. Данил Комаров, Data Scientist, Lamoda Tech
lamodatech
0
790
より良い開発者体験を実現するために~開発初心者が感じた生成AIの可能性~
masakiokuda
0
210
ドキュメント管理の理想と現実
kazuhe
1
230
Oracle Cloud Infrastructure:2025年4月度サービス・アップデート
oracle4engineer
PRO
0
120
Bazel for Ruby (RubyKaigi 2025)
p0deje
0
120
サーバレス、コンテナ、データベース特化型機能をご紹介。CloudWatch をもっと使いこなそう!
o11yfes2023
0
190
クォータ監視、AWS Organizations環境でも楽勝です✌️
iwamot
PRO
1
340
“パスワードレス認証への道" ユーザー認証の変遷とパスキーの関係
ritou
1
620
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.2k
How to Ace a Technical Interview
jacobian
276
23k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
Code Reviewing Like a Champion
maltzj
522
40k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Building Applications with DynamoDB
mza
94
6.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Designing for humans not robots
tammielis
252
25k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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