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
81
[教育訓練] 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
45
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
160
[Wheel Lab #2] Apple Service with Rails.
hechien
0
78
[Sokoos][教育訓練] Git - 1
hechien
0
150
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
110
[作業] 創意美學
hechien
0
56
[教育訓練] Rails Form Basic
hechien
1
73
Rails Layout Basic
hechien
2
120
Other Decks in Technology
See All in Technology
Terraformで構築する セルフサービス型データプラットフォーム / terraform-self-service-data-platform
pei0804
1
190
研究開発と製品開発、両利きのロボティクス
youtalk
1
530
250905 大吉祥寺.pm 2025 前夜祭 「プログラミングに出会って20年、『今』が1番楽しい」
msykd
PRO
1
980
「Linux」という言葉が指すもの
sat
PRO
4
140
Automating Web Accessibility Testing with AI Agents
maminami373
0
1.3k
Firestore → Spanner 移行 を成功させた段階的移行プロセス
athug
1
490
Generative AI Japan 第一回生成AI実践研究会「AI駆動開発の現在地──ブレイクスルーの鍵を握るのはデータ領域」
shisyu_gaku
0
310
データ分析エージェント Socrates の育て方
na0
5
530
バイブスに「型」を!Kent Beckに学ぶ、AI時代のテスト駆動開発
amixedcolor
2
580
品質視点から考える組織デザイン/Organizational Design from Quality
mii3king
0
210
Platform開発が先行する Platform Engineeringの違和感
kintotechdev
4
580
普通のチームがスクラムを会得するたった一つの冴えたやり方 / the best way to scrum
okamototakuyasr2
0
100
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Navigating Team Friction
lara
189
15k
Writing Fast Ruby
sferik
628
62k
Building an army of robots
kneath
306
46k
Music & Morning Musume
bryan
46
6.8k
A better future with KSS
kneath
239
17k
Balancing Empowerment & Direction
lara
3
620
Side Projects
sachag
455
43k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Speed Design
sergeychernyshev
32
1.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.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