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
86
[教育訓練] 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
47
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
170
[Wheel Lab #2] Apple Service with Rails.
hechien
0
84
[Sokoos][教育訓練] Git - 1
hechien
0
160
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
120
[作業] 創意美學
hechien
0
61
[教育訓練] Rails Form Basic
hechien
1
77
Rails Layout Basic
hechien
2
130
Other Decks in Technology
See All in Technology
vLLM Community Meetup Tokyo #3 オープニングトーク
jpishikawa
0
320
親子 or ペアで Mashup for the Future! しゃべって楽しむ 初手AI駆動でものづくり体験
hiroramos4
PRO
0
110
us-east-1 に障害が起きた時に、 ap-northeast-1 にどんな影響があるか 説明できるようになろう!
miu_crescent
PRO
13
4.2k
決済サービスを支えるElastic Cloud - Elastic Cloudの導入と推進、決済サービスのObservability
suzukij
2
600
Shifting from MCP to Skills / ベストプラクティスの変遷を辿る
yamanoku
4
800
ナレッジワーク IT情報系キャリア研究セッション資料(情報処理学会 第88回全国大会 )
kworkdev
PRO
0
170
NewSQL_ ストレージ分離と分散合意を用いたスケーラブルアーキテクチャ
hacomono
PRO
2
240
非情報系研究者へ送る Transformer入門
rishiyama
11
7.1k
製造業ドメインにおける LLMプロダクト構築: 複雑な文脈へのアプローチ
caddi_eng
1
560
PMBOK第8版は第7版から何が変わったのか(PMBOK第8版概要解説) / 20260304 Takeshi Watarai
shift_evolve
PRO
0
200
猫でもわかるKiro CLI(AI 駆動開発への道編)
kentapapa
0
120
OpenClawで回す組織運営
jacopen
3
690
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
37
7.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.4k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
470
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.4k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
How STYLIGHT went responsive
nonsquared
100
6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Why Our Code Smells
bkeepers
PRO
340
58k
WENDY [Excerpt]
tessaabrams
9
36k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
630
KATA
mclloyd
PRO
35
15k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
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