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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
HeChien Hsu
September 04, 2012
Technology
100
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
[教育訓練] Rails Validation Basic
HeChien Hsu
September 04, 2012
More Decks by HeChien Hsu
See All by HeChien Hsu
Using Git hosting
hechien
0
60
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
180
[Wheel Lab #2] Apple Service with Rails.
hechien
0
93
[Sokoos][教育訓練] Git - 1
hechien
0
160
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
130
[作業] 創意美學
hechien
0
71
[教育訓練] Rails Form Basic
hechien
1
87
Rails Layout Basic
hechien
2
140
Other Decks in Technology
See All in Technology
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
AIに持続⼒を与える 判断の⻑期記憶設計
eiei114
1
400
AI開発に用いられるHPC技術について
gpuunite_official
0
150
生成 AI の基礎 〜 サンプル実装で学ぶ基本原理
enakai00
7
4.5k
AI・HPC開発を支えるGPU環境の新しい選択肢 液冷GPUシステム「AquSys」の取り組み
gpuunite_official
0
130
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
290
カートの信頼性を担保するWireMockを使ったe2eテスト
ykagano
0
600
コーチングの奥義 何もしないテクニック
jinwatanabe
0
140
[potatotips #96] Give Your AI Agent the Flutter Playbook
korodroid
0
110
巨大気象データと戦う ― サロゲートモデル学習を高速化する圧縮技術
gpuunite_official
0
140
tamachi.go 誕生の裏側
rymiyamoto
1
170
FORENSIA: ローカルLLMフォレンジックハーネス
sumeshi
2
430
Featured
See All Featured
It's Worth the Effort
3n
188
29k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
45k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
270
Build your cross-platform service in a week with App Engine
jlugia
234
19k
The Curse of the Amulet
leimatthew05
2
14k
Utilizing Notion as your number one productivity tool
mfonobong
4
550
Documentation Writing (for coders)
carmenintech
77
5.5k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
290
How to train your dragon (web standard)
notwaldorf
97
6.8k
Product Roadmaps are Hard
iamctodd
55
12k
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