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
68
[教育訓練] 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
40
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
160
[Wheel Lab #2] Apple Service with Rails.
hechien
0
63
[Sokoos][教育訓練] Git - 1
hechien
0
140
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
100
[作業] 創意美學
hechien
0
43
[教育訓練] Rails Form Basic
hechien
1
57
Rails Layout Basic
hechien
2
100
Other Decks in Technology
See All in Technology
エンジニアのキャリアをちょっと楽しくする3本の軸/Three Pillars to Make an Engineer's Career More Enjoyable
kwappa
0
2.8k
IaCジェネレーターとBedrockで詳細設計書を生成してみた
tsukasa_ishimaru
3
400
【NW X Security JAWS#3】L3-4:AWS環境のIPv6移行に向けて知っておきたいこと
shotashiratori
0
430
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
230
On Your Data を超えていく!
hirotomotaguchi
2
700
地理空間データ可視化・解析・活用ソリューション Pacific Spatial Solutions (PSS)
pacificspatialsolutions
0
300
開発生産性大幅アップ!Postman VS Code拡張機能
nagix
2
460
非同期推論システムによるコスト削減と信頼性向上
koki_nishihara
0
270
プロンプトエンジニアリングでがんばらない-Agentic Workflow へ-近藤憲児
kenjikondobai
4
1k
DMM.com アルファ室採用案内資料
hsugita
1
170
GraphQL 成熟度モデルの紹介と、プロダクトに当てはめた事例 / GraphQL maturity model
mh4gf
7
1.4k
Grafana x PagerDuty Better Together
jacopen
0
150
Featured
See All Featured
Facilitating Awesome Meetings
lara
42
5.6k
Adopting Sorbet at Scale
ufuk
68
8.6k
The Invisible Customer
myddelton
114
12k
The Invisible Side of Design
smashingmag
294
49k
Fantastic passwords and where to find them - at NoRuKo
philnash
37
2.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
20
1.9k
What's new in Ruby 2.0
geeforr
337
31k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
Infographics Made Easy
chrislema
238
18k
Web Components: a chance to create the future
zenorocha
305
41k
Documentation Writing (for coders)
carmenintech
60
3.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